I want to make a clickable list in angular, after clicking on the item, it should fire a function in controller where I want to manipulate the item. The code is:
<h2>User List</h2>
<ul ng-repeat="item in items">
<li ng-repeat="(key, val) in item">
<ul>
<li>
<div ng-click="getUserChat(key)">
<a>{{key}}</a>
</div>
</li>
</ul>
</li>
</ul>
in controller:
chatApp.controller('chatController', ['$scope', '$rootScope','$state', '$http' , function($scope, $rootScope, $state, $http) {
$scope.init = function(){
$http.get("http://127.0.0.1:8000/user_list/").success(function(data) {
$scope.items = data;
console.log($scope.items);
});
};
$scope.getUserChat = function(selectedFriend){
$rootScope.selectedFriend = selectedFriend;
console.log($rootScope.selectedFriend);
}
}]);
But the console.log is not showing anything, that is the associated function getUserChat is not called. It's also not showing any error in console.