Just dipping my toes into the world of angularjs, so please bear with me! I'm experimenting with angularjs and trying to figure out how to dynamically set the search mode. I've attempted to do so with the code below, but haven't had much success.
<html>
<head>
<meta charset="utf-8">
<title>Binding</title>
</head>
<body>
<div data-ng-app="myApp">
<input type="text" data-ng-model="{{mysearch}}" />
<select data-ng-model="mysearch">
<option value="search.$">All</option>
<option value="search.name">Name</option>
<option value="search.email">Email</option>
</select>
<span>{{mysearch}}</span>
<div data-ng-controller="MyCtrl">
<table>
<tr data-ng-repeat="actor in rows.cast | filter:search">
<td>{{actor.name}}</td>
<td>{{actor.email}}</td>
</tr>
</table>
</div>
</div>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script>
<script>
var myAppModule = angular.module('myApp',[]);
myAppModule.factory('Avengers',function(){
var Avengers = {};
Avengers.cast = [{name:'joe',email:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3f55505a7f52464c564b5a115c5052">[email protected]</a>'},{name:'david',email:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="ef8b8e99868baf82969c869b8ac18c8082">[email protected]</a>'},{name:'charles',email:'<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="680b00091a040d1b5b2805111b011c0d460b0705">[email protected]</a>'}]
return Avengers;
});
function MyCtrl($scope,Avengers){
$scope.rows = Avengers;
}
</script>
</body>
</html>