EVOLUTION-MANAGER
Edit File: ngSubmit.html
<a href='https://github.com/angular/angular.js/edit/v1.3.x/src/ng/directive/ngEventDirs.js?message=docs(ngSubmit)%3A%20describe%20your%20change...#L317' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit"> </i>Improve this Doc</a> <a href='https://github.com/angular/angular.js/tree/v1.3.9/src/ng/directive/ngEventDirs.js#L317' class='view-source pull-right btn btn-primary'> <i class="glyphicon glyphicon-zoom-in"> </i>View Source </a> <header class="api-profile-header"> <h1 class="api-profile-header-heading">ngSubmit</h1> <ol class="api-profile-header-structure naked-list step-list"> <li> - directive in module <a href="api/ng">ng</a> </li> </ol> </header> <div class="api-profile-description"> <p>Enables binding angular expressions to onsubmit events.</p> <p>Additionally it prevents the default action (which for form means sending the request to the server and reloading the current page), but only if the form does not contain <code>action</code>, <code>data-action</code>, or <code>x-action</code> attributes.</p> <div class="alert alert-warning"> <strong>Warning:</strong> Be careful not to cause "double-submission" by using both the <code>ngClick</code> and <code>ngSubmit</code> handlers together. See the <a href="api/ng/directive/form#submitting-a-form-and-preventing-the-default-action"><code>form</code> directive documentation</a> for a detailed discussion of when <code>ngSubmit</code> may be triggered. </div> </div> <div> <h2>Directive Info</h2> <ul> <li>This directive executes at priority level 0.</li> </ul> <h2 id="usage">Usage</h2> <div class="usage"> <ul> <li>as attribute: <pre><code><form ng-submit=""> ... </form></code></pre> </li> </div> <section class="api-section"> <h3>Arguments</h3> <table class="variables-matrix input-arguments"> <thead> <tr> <th>Param</th> <th>Type</th> <th>Details</th> </tr> </thead> <tbody> <tr> <td> ngSubmit </td> <td> <a href="" class="label type-hint type-hint-expression">expression</a> </td> <td> <p><a href="guide/expression">Expression</a> to eval. (<a href="guide/expression#-event-">Event object is available as <code>$event</code></a>)</p> </td> </tr> </tbody> </table> </section> <h2 id="example">Example</h2><p> <div> <a ng-click="openPlunkr('examples/example-example78')" class="btn pull-right"> <i class="glyphicon glyphicon-edit"> </i> Edit in Plunker</a> <div class="runnable-example" path="examples/example-example78" module="submitExample"> <div class="runnable-example-file" name="index.html" language="html" type="html"> <pre><code><script> angular.module('submitExample', []) .controller('ExampleController', ['$scope', function($scope) { $scope.list = []; $scope.text = 'hello'; $scope.submit = function() { if ($scope.text) { $scope.list.push(this.text); $scope.text = ''; } }; }]); </script> <form ng-submit="submit()" ng-controller="ExampleController"> Enter text and hit enter: <input type="text" ng-model="text" name="text" /> <input type="submit" id="submit" value="Submit" /> <pre>list={{list}}</pre> </form></code></pre> </div> <div class="runnable-example-file" name="protractor.js" type="protractor" language="js"> <pre><code>it('should check ng-submit', function() { expect(element(by.binding('list')).getText()).toBe('list=[]'); element(by.css('#submit')).click(); expect(element(by.binding('list')).getText()).toContain('hello'); expect(element(by.model('text')).getAttribute('value')).toBe(''); }); it('should ignore empty strings', function() { expect(element(by.binding('list')).getText()).toBe('list=[]'); element(by.css('#submit')).click(); element(by.css('#submit')).click(); expect(element(by.binding('list')).getText()).toContain('hello'); });</code></pre> </div> <iframe class="runnable-example-frame" src="examples/example-example78/index.html" name="example-example78"></iframe> </div> </div> </p> </div>