As in the title. I would like to increment value inside directive template.
I tried this:
var ngApp = angular.module("ngApp", []);
ngApp.controller("AppCtrl", function(){
var app = this;
app.counter = 1;
app.foo = function(){
app.counter++;
return app.counter;
}
});
ngApp.directive("box", function(){
return {
restrict: "E",
template: "<div>BOX - {{app.foo()}}<div>"
}
});
But it does not work. Any ideas?
$index. Check out ngRepeat.