In my controller, I have the following array of users, which will be displayed by iteration in the partial html template
in controller:
vm.users = [
{"username": "johnDoe", "address": "Saltlake City, UT", "age": 34},
{"username": "janeDoe", "address": "Denver, CO", "age": 33},
{"username": "patrickDoe", "address": "San Francisco, CA", "age": 35}
];
partial html code:
<div ng-repeat="user in mapView.users">
<my-customer info="user"></my-customer></div>
myCustomer directive: I wish to increment the customer's age when the mouseover event happens on the customer. Is it possible to do this in the directive?
angular
.module('angularApp')
.directive('myCustomer', function() {
return {
restrict: 'E',
link: function(scope, element) {
element.bind('mouseover', function(e) {
e.target.age++; // this is not working, need help here!
console.log(e.target, 'mouseover');
});
},
scope: {
customerInfo: '=info'
},
templateUrl: 'views/directives/myCustomer.html'
};
}); //myCustomer
myCustomer template:
<span>
<label class="label-success">Username: {{customerInfo.username}}</label>
</span>
<span>
<label class="label-default">{{customerInfo.address}}</label>
</span>
<span>
<label class="label-danger">{{customerInfo.age}}</label>
</span>