I have a view like so:
<div ng-controller= "test" ng-init = "doit()">
<span>{{testval}}</span>
</div>
The view's controller looks like this:
function test($scope){
var counter = 0;
$scope.doit = function(){
console.log('switched to view');
$scope.testval = counter++;
};
};
The first time I switch to the view controlled by 'test', it shows '0'. After that, it shows nothing, but the console.log continues firing. How can I set this up to execute 'doit' each time I switch to the view and successfully update the view by modifying $scope?
Thanks