Controller 'ngModel', required by directive '…', can't be found

后端 未结 4 1013
甜味超标
甜味超标 2020-12-10 00:38

What\'s going on here?

Here is my directive:

app.directive(\'submitRequired\', function (objSvc) {
    return {
        require: \'ngModel\',
                


        
相关标签:
4条回答
  • 2020-12-10 00:53

    You can also remove the line

      require: 'ngModel',
    

    if you don't need ngModel in this directive. Removing ngModel will allow you to make a directive without thatngModel error.

    0 讨论(0)
  • 2020-12-10 00:56

    I faced the same error, in my case I miss-spelled ng-model directive something like "ng-moel"

    Wrong one: ng-moel="user.name" Right one: ng-model="user.name"

    0 讨论(0)
  • 2020-12-10 00:58

    As described here: Angular NgModelController, you should provide the <input with the required controller ngModel

    <input submit-required="true" ng-model="user.Name"></input>
    
    0 讨论(0)
  • 2020-12-10 01:09

    One possible solution to this issue is ng-model attribute is required to use that directive.

    Hence adding in the 'ng-model' attribute can resolve the issue.

    <input submit-required="true" ng-model="user.Name"></input>
    
    0 讨论(0)
提交回复
热议问题