Having my variables bound to this
in the controller and using controllerAs: 'game'
in the route designation allows me to include them in the HTML using {{game.var}}
. At times, I find myself binding objects that I want to display, which leads to repetitive code such as {{game.object.a}}
, {{game.object.b}}
, {{game.object.c}}
.
In a previous project that used Meteor, I was able to set the data context using the with
keyword.
{{#with object}}
{{a}}
{{b}}
{{/with}}
However, in Angular, I haven't come across a feature that is similar to this. The closest workaround I have found is adding the attribute
ng-repeat="object in [game.object]"
. While this does work, it lacks semantic clarity. Additionally, it results in a momentary display of a second element when game.object
changes, being loaded before the first one is erased.
Is there a more efficient solution to this issue?