I have to access a function to the scope of the clicked object in angular. I have to write to the console the id of the object, but without passing the object to the called function by the click event.
Could some one help me with my problem?
Below is the code what I have achieved so far.
<ul data-ng-app="myApp" data-ng-controller="myController">
<li data-ng-repeat="x in names" data-ng-bind="x.title" data-ng-click="fnct(x)"></li>
</ul>
<script>
angular.module('myApp', []).controller('myController', function($scope) {
$scope.names = [{id: 2345, title: 'title1'}, {id: 9876, title: 'title2'}];
$scope.fnct = function(obj) {
console.log(obj.id);
}
});
</script>