Search code examples
angularjsangularjs-directiveng-submit

ng-submit doesn't work in angular js


I know that there are a lot of other similar questions but I didn't find the answer there.

<html ng-app="app" ng-controller="AppController">    
...
    <form class="navbar-form navbar-left" role="search" ng-submit="alert()">
         <div class="form-group">
             <input type="text" class="form-control search" ng-model="text" />
         </div>
         <button type="submit" class="btn btn-default icon-default icon-search">Submit                          </button>
    </form>
</html>

Solution

  • Try to submit the form by adding ng-click in the button tag and call submit function by passing your form in the ng-click. The function is where you write your logic in the controller. submit