当表格不在手风琴标签内时,以下表格可以正确使用验证,但是当它在手风琴标签内部时,即使方法也不会触发。
HTML
<div ng-controller="myCtrl">
<form name="myForm" role="form" ng-submit='myAccount()' novalidate="novalidate">
<input type="text" name="myName" ng-model='myName' required>
<div ng-show="myForm.myName.$dirty && myForm.myName.$invalid || submitted">
<small class="error" ng-show="myForm.myName.$error.required">
Your Name is required
</small>
</div>
<div>
<button type="submit" ng-click="submitted = true">Add</button>
</div>
</form>
</div>
控制器
app.controller('myCtrl', ['$scope','$location', '$log', function($scope,$location,$log)
{
$scope.myAccount = function()
{
if($scope.myForm.$valid)
{
$log.log('Valid Form');
}
else
{
$log.log('Validation Failed');
}
}
}]);
我想在以下手风琴标签内使用上述表格,因为它应该在手风琴中可见。但问题是,当我将它放在手风琴标签内时,ng-submit将无法正常工作,甚至不会出现任何错误。这有解决方案吗?它是手风琴标签中的一个错误吗?
<accordion close-others="true">
<accordion-group>
<accordion-heading>
<!-- form html content goes here -->
</accordion-group>
</accordion>
答案 0 :(得分:0)
$scope.pho.myAccount = function()
{
if($scope.myForm.$valid)
{
$log.log('Valid Form');
}
else
{
$log.log('Validation Failed');
}
}
<form name="myForm" role="form" ng-submit='pho.myAccount()' nov ..
检查这两个修改:)不确定