search

Home  >  Q&A  >  body text

angular.js - How to silently perform copy operations on the page in angular?

<input name="phone" ng-model="phone" type="text" />
<input name="code" ng-model="code" type="text" />
{{disabled = !(code && phone)}}
<button ng-class="{disabled:disabled}" type="button" >OK</button>

The above code can achieve the effect
But the result of {{disabled = !(code && phone)}} will be displayed
Put it in ng-if and it won’t be executed. I don’t want to put it in a hidden p

Is there any more elegant solution? For example, put it in a tag like ng-init

某草草某草草2774 days ago597

reply all(1)I'll reply

  • 黄舟

    黄舟2017-05-15 16:51:42

    Isn’t there ng-disabled?

    <button ng-disabled="!(code && phone)" type="button" >确定</button>
    

    reply
    0
  • Cancelreply