Angularjs 错误引用错误:\未在h.$scope.setSelectedClient上定义?
这是我的controller.jsAngularjs 错误引用错误:\未在h.$scope.setSelectedClient上定义?,angularjs,angularjs-scope,angularjs-ng-repeat,Angularjs,Angularjs Scope,Angularjs Ng Repeat,这是我的controller.js var animateApp = angular.module('animateApp'); animateApp.controller('portofolioController', ['$scope', function ($scope) { $scope.selectedCategory = []; $scope.categoryList = [{ id: 1, name: 'webdesign' }, { id: 2,
var animateApp = angular.module('animateApp');
animateApp.controller('portofolioController', ['$scope', function ($scope) {
$scope.selectedCategory = [];
$scope.categoryList = [{
id: 1,
name: 'webdesign'
}, {
id: 2,
name: 'webdevelop'
}, {
id: 3,
name: 'logo'
}];
$scope.clients = [{
name: '1',
designation: 'descriere',
category: {
id: 1,
name: 'webdesign'
}
}, {
name: '2',
designation: 'descriere',
category: {
id: 2,
name: 'wendevelop'
}
},
{
name: '3',
designation: 'descriere',
category: {
id: 3,
name: 'logo'
}
},
{
name: '4',
designation: 'descriere',
category: {
id: 4,
name: 'webdesign'
}
},
{
name: '5',
designation: 'descriere',
category: {
id: 5,
name: 'webdevelop'
}
}];
$scope.setSelectedClient = function () {
var id = this.category.id;
if (_.contains($scope.selectedCategory, id)) {
$scope.selectedCategory = _.without($scope.selectedCategory, id);
} else {
$scope.selectedCategory.push(id);
}
return false;
};
}]);
这是在我的html文件中,是一个按钮,当它按下时,我的列表是按类别排序的。我在filter.js中有一个过滤器,它只显示这个类别中的字段
<li data-ng-repeat="category in categoryList"> <a data-ng-click="setSelectedClient()" class="btn">{{category.name}}</a></li>
{{category.name}
当我点击点击按钮时,我收到一个错误。我在找这样的帖子,但什么也找不到。
ReferenceError:\未在h.$scope.setSelectedClient中定义(http://localhost/Portofolio2/js/controllers.js:60:13)
在$scope.setSelectedClient函数中,有一个对未声明对象“\ux”的引用
if (_.contains($scope.selectedCategory, id)) {
检查是否遗漏了在$scope.setSelectedClient函数中包含任何lib文件,如果存在对未声明对象“\ux”的引用
if (_.contains($scope.selectedCategory, id)) {
检查是否遗漏了包含任何lib文件。contains是库下划线或Lodash中的一个方法 包括该库或使用普通JavaScript复制功能
\uCONTAINS
是来自库下划线或Lodash的方法
包括该库或使用普通JavaScript复制功能