Kakul Sarma
Kakul Sarma

Reputation: 303

ng-submit is not working

I HAVE A FORM BUT NG SBMIT DOESNOT CALL THE FUNCTION

I dont understand why this form not submitting . i have check every thing but it not even call the alert button also

HTML

 <form role="form" name="frmCashback" method="post" ng-submit="CashbackUser(frmCashback, Rates)">
                     <!-- Personal Details Start -->
                     <div class="well">
                        <legend> Cashback Details </legend>
                        <div class="row">
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label for="Store">Store:</label>
                                 <select name="Store" class="form-control" ng-model="Rates.Store" ng-options="stores.StoreID as stores.StoreName for stores in StoreList"  >
                                    <option value="">Select</option>
                                 </select>
                              </div>
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label for="Store">Category:</label>                           
                                 <select name="Category" class="form-control" ng-model="Rates.Category" ng-options="Cate.CategoryID as Cate.CategoryName for Cate in CategoryList"  >
                                    <option value="">Select</option>
                                 </select>
                              </div>
                              <!-- Modal -->
                              <!---------Model End-------->
                           </div>
                           <div class="col-md-4">
                              <div class="form-group">
                                 <label for="usr">Cash Back Rate:</label>
                                 <input type="text" class="form-control" name="Cashback" id="Cashback" ng-model="Rates.Cashback" required>
                              </div>
                           </div>
                        </div>
                        <!---------Model End-------->
                     </div>
               </div>
               <div class="row">                        
               <div class="col-md-12">                                
               <button class="btn btn-primary" type="submit">Add Cashback</button>
               </div>
               </div>
            </div>
            <!-- Personal Details End -->
            </form>

Here is my controller

CONTROLLER

$scope.CashbackUser = function(frm, Rates) {

        alert('Hi');

        //query_params.Status = CheckStatus.Action;
        //console.log(Rates);   

    }

I have check :

function is within the controller I am figthing with this for 4 hr kindly help me.

Upvotes: 0

Views: 64

Answers (2)

krishnakumar sekar
krishnakumar sekar

Reputation: 663

Your template seems to be having error ,form submit will not work if your template having error think so

<!---------Model End-------->
</div>
</div>

Upvotes: 1

Coder002
Coder002

Reputation: 275

In your form, you can use this:

ng-submit="CashbackUser()"

And in your controller:

$scope.CashbackUser = function(){ 
 console.log($scope.frmCashback);
 console.log($scope.Rates);
}

Upvotes: 0

Related Questions