I am trying to trigger an action in my controller when the view loads. Here's the code snippet from my controller:
$scope.$on('$viewContentLoaded', function () {
//View content is fully loaded here !!
if ($scope.hasErrors === true) {
showError('Error message');
$scope.errorMessage = 'error';
}
});
One issue I am facing is that this event seems to fire multiple times. I suspect it has something to do with the angular digest cycle. Another strange thing I noticed is that when I debug JavaScript in Firefox, it reaches the logical expression even when
$scope.hasErrors = false
it stops at the line
$scope.errorMessage = 'error';
Could this problem be specific to Firefox or is there something else at play?