이 피들을 검토하십시오. 컨트롤러에서 '필터'를 사용하려고합니다. 단추로 연결된 텍스트 상자에 제공된 검색 기준을 기반으로 검색하려는 데이터 배열이 있습니다.angularJS의 컨트롤러에서 '필터'사용
사용자가 텍스트를 입력 한 다음 Enter 키를 눌러 검색합니다. 사용자가 텍스트 상자에서 뒤로 키를 누르면 원래 목록이 다시 나타납니다.
필자는 컨트롤러에서 필터를 적용하고 싶습니다. 그래서 나는 가지고있는 것들과 일해야한다.
상담하십시오.
<div ng-app="myApp">
<div ng-controller="MyCtrl">
<input type='text' data-ng-model='search'>
<button ng-click='newList()'> </button>
<table> <tr data-ng-repeat= "item in items"><td> {{item.name}} </td></tr></table>
</div>
</div>
var myApp = angular.module('myApp',[]);
function MyCtrl($scope, $filter) {
$scope.items= [
{
id: 0,
name: "Noman",
email: "[email protected]"},
{
id: 1,
name: "Sameer",
email: "[email protected]"},
{
id: 2,
name: "Humair",
email: "[email protected]"}
];
$scope.newList = function() {
$scope.items = $filter('filter')($scope.items,'name',$scope.search)
}
}
$ scope.items = $ 필터 ('필터') ($ true로 scope.items, $의 scope.search) 이 줄은 것 같아요 같이해야한다 . 하지만 텍스트 상자에서 텍스트를 꺼내면 목록을 다시 표시하는 방법. – Sid7201
http://angulartutorial.blogspot.in/2014/03/filtering-concept-in-angular-js.html – Prashobh