I want to initialize an angular variable with local scope BWCount.
When i use ng-init I get the following error Error: $parse:syntax
But when I use ng-int (It was a typo, but turns out to be a surprising serendipity), it works fine and I can even use that variable in other markups.
What is happening here? Am I using the incorrect syntax for ng-init? And what is this ng-int (I don't have any custom directive called ngInt)
I am using Visual studio 2013 and have have the following markup:
<div ng-int="{{BWCount=(oCurrentDepartment.oMachineAccount|sumByKey:'BWCOUNT')}}">{{BWCount}}</div>
Notice ng-int
ng-init
expects an angular expression, so you must not have {{ }}
around it.
Your code works simply because angular considers ng-int
as a basic HTML attribute, and evaluates the expression surrounded by {{ }}
at each digest cycle. Not just at initialization.
ng-init
should be avoided anyway. That code should be in your controller.