简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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