javascript - AngularJS validation of asynchronously loaded form -


i building angularjs application includes modal windows contain forms , loaded dom asynchronously (when appropriate button clicked). forms work fine, cannot check if valid. here's example:

html

<div ng-app="myapp" ng-controller="myctrl">     <form novalidate name="myform" ng-submit="submitform(myform)">         <input type="text" required ng-model="myname" />     </form> </div> 

javascript

var app = angular.module('myapp', []); app.controller("myctrl", function($scope) {     $scope.submitform(form) {         if(form.$valid) {             // http stuff here         }     }; }); 

if form loaded asynchronously, form variable has value nan , form.$valid undefined. however, if load rest of page, works fine. know how force angularjs populate scope variable form? thanks!

when include form using ng-include childscope created. parent , childscope cant access eachothers scopes. therefore .$valid comes empty.

i had similiar issue other day , got working solution suited me in thread:

angularjs $setvalidity on childscope form


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -