ng-click not working with ng-if

后端 未结 4 1868
抹茶落季
抹茶落季 2021-02-06 01:38

Why does the second button not work, when ng-if is used?

I want to realize a button that is present only when the model value is set / not \"\"/ not nul

4条回答
  •  爱一瞬间的悲伤
    2021-02-06 01:48

    The button doesn't work because of the nested scope created by ng-if. The blub bound to the second button is not the same blub that's bound to the first one.

    You can use ng-show instead of ng-if, since it uses its parent's scope, but that's just avoiding the problem instead of solving it. Read about nested scopes so you can understand what actually happened.

    Also, check this out: fiddle

提交回复
热议问题