angular-promise-buttons icon indicating copy to clipboard operation
angular-promise-buttons copied to clipboard

Submit button with ng-if

Open cmolina opened this issue 7 years ago • 1 comments

I have a form like this

<form ng-submit="yourServiceCaller()"
      promise-btn>
  <button type="submit" ng-if="maybe">MyBtn</button>
</form>

By debugging, I found that getSubmitBtnChildren does not find buttons with the ng-if directive.

A workaround is to use ng-show instead. Is there any way to wait until all those ng-if are already resolved?

cmolina avatar Apr 18 '17 17:04 cmolina

Thanks for digging into this. As it is currently implemented the button needs to be present in the dom once the promise-btn directive (in this case on the form element) is $compiled.

Currently there is also no easy way to set this up as the button elements need event handlers to be attached. Listening for dom changes inside of the form would be complicated and costly performancewise, but I'm open to suggestions!

One alternative would be to use a child directive on the buttons, but this would require a huge refactor of the component, make the usage more complicated and possibly break existing implementations.

johannesjo avatar Apr 19 '17 14:04 johannesjo