Hi,

- The directive ng-if and every other directive that remove/add DOM 
elements involves some performance hit. Try using ng-show that only 
adds/removes a class to the element (an operation that is a lot faster).
- Be sure that foo.bar resolves to a boolean value, if this is not the 
case, then write ng-if="!!foo.bar" as ng-if puts a $watch on the expression 
without coalescing it to a boolean.

BTW, the fact that you can see both elements at the same time involves that 
there is /something/ happening in between. In most cases, you should check 
the number of active  $watch running at the page.

Regards,
  Lucas


On Sunday, December 15, 2013 6:30:53 PM UTC-3, Rob Nikander wrote:
>
> Hi,
>
> I have two elements, and I need to display one or the other, something 
> like this...
>
>    <input ng-if='foo.bar' ...>
>    <input ng-if='!foo.bar' ...>
>
> Another checkbox is bound to ng-model='foo.bar'.  When I check/uncheck it, 
> the page momentarily displays *both* elements, which looks like crap. 
> That's not normal right? Any idea why it would doing that and how to stop 
> it? The same thing happens with switch/when/otherwise. The page doesn't 
> seem to have performance problems.  I just upgraded to 1.2.5 to see if that 
> fixed it - no.  The only non-standard thing I've got is ui-router, but I 
> haven't noticed it causing any problems.
>
> Rob
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to