I sometimes find myself using multiple expressions checking on a single flag to control the state of some template, in this example, a Facebook log in button.
On a second look, however, I noticed this pattern might bear a significant performance drawback for making Angular have to update the DOM in multiple places every time a single flag changes.
Mind you, this is a login-button directive so it's not supposed to alternate too much, it's just the latest use case I have on my hands at the moment. Other components might feature busier templates, both in condition expressions and in live updates to the DOM.
Am I just being paranoid? Or is my concern regarding performance impact here justified? Do you know of a better way to implement this (for example: a single ng-if
)?
<div class="fb-login">
<h3 class="fb-login-prompt" unselectable="on">{{ isUserConnected ? 'Welcome' : 'For points' }}</h3>
<button type="button" class="btn btn-login-fb {{isUserConnected ? 'connected' : ''}}" ng-click="facebookHandler()" unselectable="on">
<span ng-if="isUserConnected"><img class="btn-fb-picture" ng-src="{{user.image_thumbnail}}" />{{user.name}}</span>
</button>
</div>