How to bind an AJAX loaded form to 'ngModel' [close]

Retrieved from http://examle.com/ajax/login.html :

<form method="post" action="/login.html" name="formLogin" data-ng-model="formLogin" data-ng-submit="submitLogin($event)" novalidate="novalidate" >
   <input type="hidden" csrf="csrf" data-ng-model="formLogin.csrf" value="" name="LoginForm[csrf]">

   <input type="text" data-ng-minlength="2" data-ng-required data-ng-model="formLogin.email" placeholder="e-mail" autofocus="autofocus" name="LoginForm[email]"></div>
   <span class="error" ng-show="formLogin['LoginForm[email]'].$error.required">Required!</span>

   <input type="text" data-ng-minlength="2" data-ng-required data-ng-model="formLogin.password" placeholder="password" autofocus="autofocus" name="LoginForm[password]"></div>
   <span class="error" ng-show="formLogin['LoginForm[password]'].$error.required">Required!</span>

   <button ng-disabled="formLogin.submitted" name="login-button" class="btn btn-primary" type="submit">OK</button>
</form>

      

The directive code looks like this:

app.directive('formLogin', function(){
   return {
      require: 'ngModel',
      link: function(scope, element, attrs, ngModelCtrl) {
          var inputs = element[0].querySelectorAll('input');
      }
   };
});

      

In the classic example , if you specify a name for a form, the form controller will be published to the appropriate scope under that name. Is it possible to do something like AJAX for a loaded form? The problem is with the validation inputs after the form has loaded.

+3


source to share





All Articles