searchKeyword not working in AngularJS filter -
i writing app using angularjs on front end. want search through table word/field; 1 search box everything. according article here: http://hello-angularjs.appspot.com/searchtable can use filter: searchkeyword this.
this code, , not working expected.
<label>search: <input ng-model="searchkeyword"></label> <table ng-repeat="post in posts | orderby: sort | filter: searchkeyword"> <tr> <td> {{index(post)}} </td> <td> {{post.title}} </td> <td> {{post.author}} </td> <td> {{post.content}} </td> <td> {{post.date | date: "d/m/yyyy"}} </td> </tr> </table>
what should do? thank you
try this:
controller
$scope.posts = [ {title:'title one', author:'author one', content: 'content one'}, {title:'title two', author:'author two', content: 'content two'}, {title:'title three', author:'author three', content: 'content three'} ]; $scope.searchkeyword = ''; $scope.sort = 'title';
view
<label>search: <input ng-model="searchkeyword"> </label> <table ng-repeat="post in posts | orderby: sort | filter: searchkeyword"> <tr> <td> {{post.title}} </td> <td> {{post.author}} </td> <td> {{post.content}} </td> </tr> </table>
Comments
Post a Comment