How can I conditionally require form inputs with AngularJS?

后端 未结 5 968
一生所求
一生所求 2020-11-27 10:08

Suppose we\'re building an address book application (contrived example) with AngularJS.

We have a form for contacts that has inputs for email and phone number, and w

5条回答
  •  再見小時候
    2020-11-27 10:47

    There's no need to write a custom directive. Angular's documentation is good but not complete. In fact, there is a directive called ngRequired, that takes an Angular expression.

    
    
      
    

    Here's a more complete example: http://jsfiddle.net/uptnx/1/

提交回复
热议问题