If I have an ng-click like this: ng-click="buggy()" and click on no error message is generated on the console.
This makes it a bit tricky to debug.
Why aren't error messages generated? Anything I can do?
If I have an ng-click like this: ng-click="buggy()" and click on no error message is generated on the console.
This makes it a bit tricky to debug.
Why aren't error messages generated? Anything I can do?
Angular expressions
Actually, It's not something special with
ng-click
, It's the default behavior of angular expressions .buggy()
is not evaluated with regular javascript. It is evaluated with$parse
.$parse
evaluates expressions and returns a function that would run against a scope.$parse
only log errors when the expression is not valid.Angular expression evaluation is forgiving , I cannot think of any way to pass it.
Why expressions are forgiving?
A rationale for Angular expressions to be forgiving of undefined and null has to do with data binding. Bound variables may initially be undefined or null when they are compiled into the DOM- one really clear example is when the bound variable is dependent on a promise. The Angular team decided that rather than having error messages popping up until that promise is resolved it'd be better to continue silently.
From the Angular guide to expressions:
See Also: https://groups.google.com/forum/m/#!topic/angular/HRVOUKEHLFw
Angular expressions: