简体   繁体   English

AngularJS ng-submit在手风琴标签中不起作用

[英]AngularJS ng-submit Not working inside accordion tags

Following form works correctly with validations when its not inside the accordion tags, but when its inside the accordion tags even the methods won't fire. 当它不在手风琴标签内,但当它在手风琴标签内时,以下形式甚至可以正确使用验证,即使该方法也不会触发。

HTML 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>

Controller 调节器

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');
        }
    }
}]);

I want to use the above form inside the following accordion tags since it should be visible inside accordion. 我想在以下手风琴标签中使用上面的形式,因为它在手风琴中应该可见。 But the issue is when I place it inside the accordion tags the ng-submit won't work and it doesn't even gives any errors. 但是问题是,当我将其放在手风琴标签中时,ng-submit将无法正常工作,甚至不会出现任何错误。 Is there a solutions to this? 有解决方案吗? is it a bug in accordion tags? 这是手风琴标签中的错误吗?

<accordion close-others="true">
    <accordion-group>
         <accordion-heading>
                <!-- form html content goes here -->                
         </accordion-group>          
</accordion>
$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 ..

check with these two modifications :) not sure 检查这两个修改:)不确定

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM