Skip to content
This repository has been archived by the owner on Aug 29, 2023. It is now read-only.

md-button: lag and duplication when toggled with ng-if directly #936

Closed
epelc opened this issue Dec 12, 2014 · 4 comments
Closed

md-button: lag and duplication when toggled with ng-if directly #936

epelc opened this issue Dec 12, 2014 · 4 comments

Comments

@epelc
Copy link
Contributor

epelc commented Dec 12, 2014

If you use an ng-if directly on an md-button to toggle it there is noticble lag when toggling it on/off. This does not show up if you use ng-show or ng-hide instead. It also doesn't happen if you put the ng-if on a div surrounding your md-button instead of directly on the md-button.

Also if you toggle the ng-if rapidly you end up with several md-button's for a short time until they are they are removed. It essentially duplicates the md-button for a few seconds.

Example plunkr:
http://plnkr.co/edit/Cp5UOp0WC6G1fHR2kHiy?p=preview

This may also affect md-text-field although I haven't tested it yet.

@epelc epelc changed the title md-button: lag and multiple duplication when toggled with ng-if directly md-button: lag and duplication when toggled with ng-if directly Dec 12, 2014
@PaulMougel
Copy link
Contributor

#678 seems to be related. Maybe @robertmesserle will be able to help?

@dapids
Copy link
Contributor

dapids commented Feb 16, 2015

It happens just the same with ng-repeat.

Here is a plunkr: http://plnkr.co/edit/IY7I0zzDFuboBUc1wYej?p=preview

@dwilt
Copy link

dwilt commented Aug 27, 2015

Would also like to note that this has nothing to do with material as it was happening in my project (which doesn't use material). I had just regular <button> elements with ng-if's applied and it was still happening to me. Solution: Wrap a div around the buttons and move the ng-if to it:

Has both showing for a moment:

<button ng-if="ctrl.someCondition()">Showing if someCondition() is true</button>
<button ng-if="!ctrl.someCondition()">Showing if someCondition() is false</button>

Doesn't:

<div ng-if="ctrl.someCondition()">
  <button>Showing if someCondition() is true</button>
</div>
<div ng-if="!ctrl.someCondition()">
  <button>Showing if someCondition() is false</button>
</div>

@alexalannunes
Copy link

Thanks @dwilt

@angular angular locked as resolved and limited conversation to collaborators Mar 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

7 participants