In angularjs we are having ng-disabled directive, why ng-enabled directive is not provided by the framework as we are having ng-show and ng-hide

shA.tAvinash Solanki提出了一个问题:In angularjs we are having ng-disabled directive, why ng-enabled directive is not provided by the framework as we are having ng-show and ng-hide,或许与您遇到的问题类似。

回答者dfsq给出了该问题的处理方式:

The reason why there is no ngEnabled directive in Angular is rather semantical - there is simply nothing corresponding to it in HTML specification. At the same time there is already ngDisabled directive that works with disabled attribute. For the same reason, there is no ngUnchecked directive, because there is already ngChecked that sets/removes checked attribute.

Now, the reasonable question: why we have both ngShow and ngHide then? Well it's just for convenience in this case I guess, because having both ngShow and ngHide is not more confusing than ngShow alone, but at the same time it's very handy to have both.

希望本文对你有帮助,欢迎支持JavaScript中文网