I see this error when I press F12 in chrome. There seems to be no problems.
My html code
<ul class="dropdown-menu" role="menu" ng-controller="CounterController">
<li ng-repeat="item in messages"><a href="">{{item.name}}</a></li>
</ul>
Here is my js file. Any idea why? The version of angualr I am using is 1.6.1 angular controller code
angular
.module('myApp.counter_controller', [])
.controller('CounterController', ['$scope', '$filter', function($scope, $filter) {
'use strict';
$scope.messages = [{
name : 'ENG',
read : false
}, {
name : 'JPN',
read : false
}, {
name : 'CHI',
read : false
}, ];
$scope.setRead = function(item, $event) {
$event.preventDefault();
$event.stopPropagation();
item.read = true;
};
$scope.setUnread = function(item, $event) {
$event.preventDefault();
$event.stopPropagation();
item.read = false;
};
$scope.setReadAll = function($event) {
$event.preventDefault();
$event.stopPropagation();
angular.forEach($scope.messages, function(item) {
item.read = true;
});
};
$scope.unseenCount = $filter('filter')($scope.messages, {
read: false
}).length;
$scope.$watch('messages', function(messages) {
$scope.unseenCount = $filter('filter')(messages, {
read: false
}).length;
}, true);
}]);
You may have done some file arranging problem.
please see code it is working fine :code link
output:Main Output
you may need to wrap them in an anonymous function like so
(function(){
var myApp = angular.module('myAPP', ['ngRoute']);
storehubs.controller('welcome',['$scope',function($scope){
$scope.pageClass="welcome_page";
}]);
})();
Also your html should include ng-app="myApp" and your links to angular.min.js and yourapp.js files need to be in the head tag of your html.
Look at some docs https://docs.angularjs.org/guide/controller
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With