app.controller('thumbnailController', function ($scope) {
debugger
$scope.customers = [
{ name: 'ave Jones', city: 'Phoenix' },
{ name: 'amie Riley', city: 'Phoenix' }
];
$scope.SortCustomer = function (searchitem) {
$scope.customers = [
{ name: 'ave Jones', city: 'Phoenix' },
{ name: 'amie Riley', city: 'Phoenix' }
];
if (searchitem != 'all') {
var filter = [];
var items = $scope.customers;
// $scope.angular.forEach
var i = 0;
for (i; i < 7; i++) {
if (items[i].name[0] === searchitem) {
console.log('pushing');
filter.push(items[i]);
}
}
$scope.customers = filter; // I have update my customers list hear but it not reflecting on dom
}
};
})
答案 0 :(得分:0)
使用类似于范围的方法,您应该将其与ng-click
<button ng-click="SortCustomer()">click me</button>
虽然在JS中没有将searchitem作为参数传递,但您应该使用分配给您正在使用的输入的模型
$scope.SortCustomer = function (searchitem) {
一旦你做了一个探索者或者jsfiddle,我就能回答更具体的问题
干杯