I'm learning AngularJS by doing my first app with it. As far as now, everything was working ok and I'm pretty excited :)
But now I have a console.log that is totally confusing me, and I'm start thinking I've completely missed something.
I have a simple tag bound to a controller:
<h2 ng-controller='HeaderController' ng-show='data.actualSection > 0'>
{{titleForSection()}}
</h2>
The controller is very simple:
uxctModule.controller ('HeaderController', function ($scope, ModelData){
$scope.data = ModelData;
$scope.titleForSection = function () {
console.log ("RETURNING IT");
return ("I SHOULD RETURN YOU SOMETHING");
}
});
What's really confusing me is that I've noticed that every time something is changing in the model, the function is triggered. How can the controller be executing the function constantly without a $watch in it?
titleForSection()
in your template? In general should bind function calls to buttons, etc. but not put them directly in templates.