I'm new on Angularjs and i have this error ReferenceError: _ is not defined at h.$scope.setSelectedClient?

Posted by user3381078 on Stack Overflow See other posts from Stack Overflow or by user3381078
Published on 2014-05-28T15:21:07Z Indexed on 2014/05/28 15:24 UTC
Read the original article Hit count: 155

Filed under:
|

Here is my controller.js .

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;
};  

}]);

And this is in my html file, is a button and when it pressed, the list i have is sort by category. I have a filter in filter.js who show just the fields in this category.

   <li data-ng-repeat="category in categoryList"> <a data-ng-click="setSelectedClient()" class="btn">{{category.name}}</a></li> 

I'm receving an error when i click on click on button. I'm looking posts like that but i can't find anything. ReferenceError: _ is not defined at h.$scope.setSelectedClient (http://localhost/Portofolio2/js/controllers.js:60:13)

© Stack Overflow or respective owner

Related posts about angularjs

Related posts about angularjs-scope