如果我将$ scope放在控制器中,我应该放在哪里?
angular.module('FilterInControllerModule', []).
controller('FilterController', ['filterFilter', function(filterFilter) {
this.array = [
{name: 'Tobias'},
{name: 'Jeff'},
{name: 'Brian'},
{name: 'Igor'},
{name: 'James'},
{name: 'Brad'}
];
this.filteredArray = filterFilter(this.array, 'a');
}]);
答案 0 :(得分:0)
在数组中作为控制器方法的第二个参数。但是您不需要指定整个数组。您可以将其作为控制器功能的参数传递。
controller('FilterController', function(filterFilter, $scope) {
this.array = [
{name: 'Tobias'},
{name: 'Jeff'},
{name: 'Brian'},
{name: 'Igor'},
{name: 'James'},
{name: 'Brad'}
];
this.filteredArray = filterFilter(this.array, 'a');
});