I have my variables bound to this
in my controller, and in my route designation I use controllerAs: 'game'
. This allows me to include them in my HTML with {{game.var}}
. Sometimes, I bind objects that I want to display, but this forces me to write repeatedly {{game.object.a}}
, {{game.object.b}}
, {{game.object.c}}
.
In a previous project using Meteor, I could set the data context with the with
keyword.
{{#with object}}
{{a}}
{{b}}
{{/with}}
but I don't see a similar feature to this in Angular. The closest I've been able to make work is adding the attribute ng-repeat="object in [game.object]"
. This works, but it isn't very semantic. This also causes me to get a quick flash of a second element when game.object
changes, as the new one loads before the first one is erased.
Is there a better solution to this problem?