PageRenderTime 43ms CodeModel.GetById 33ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/app/public/js/libs/angular/docs/partials/api/ng.directive:ngSubmit.html

https://bitbucket.org/kaiquewdev/front-in-sampa-example
HTML | 71 lines | 69 code | 2 blank | 0 comment | 0 complexity | c3265b078ecb0ec6a48ef8f311c8b4ea MD5 | raw file
 1<h1><code ng:non-bindable="">ngSubmit</code>
 2<span class="hint">(directive in module <code ng:non-bindable="">ng</code>
 3)</span>
 4</h1>
 5<div><h2 id="Description">Description</h2>
 6<div class="description"><p>Enables binding angular expressions to onsubmit events.</p>
 7
 8<p>Additionally it prevents the default action (which for form means sending the request to the
 9server and reloading the current page).</p></div>
10<h2 id="Usage">Usage</h2>
11<div class="usage">as attribute<pre class="prettyprint linenums">&lt;form ng-submit="{expression}"&gt;
12   ...
13&lt;/form&gt;</pre>
14as class<pre class="prettyprint linenums">&lt;form class="ng-submit: {expression};"&gt;
15   ...
16&lt;/form&gt;</pre>
17<h3 id="Parameters">Parameters</h3>
18<ul class="parameters"><li><code ng:non-bindable="">ngSubmit �&#x20AC;&#x201C; {expression} �&#x20AC;&#x201C; </code>
19<p><a href="guide/expression">Expression</a> to eval.</p></li>
20</ul>
21</div>
22<h2 id="Example">Example</h2>
23<div class="example"><h4>Source</h4>
24<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-121" source-edit-css="" source-edit-js="script.js-120" source-edit-unit="" source-edit-scenario="scenario.js-122"></div>
25<div class="tabbable"><div class="tab-pane" title="index.html">
26<pre class="prettyprint linenums" ng-set-text="index.html-121" ng-html-wrap=" angular.js script.js"></pre>
27<script type="text/ng-template" id="index.html-121">
28 
29 <form ng-submit="submit()" ng-controller="Ctrl">
30   Enter text and hit enter:
31   <input type="text" ng-model="text" name="text" />
32   <input type="submit" id="submit" value="Submit" />
33   <pre>list={{list}}</pre>
34 </form>
35</script>
36</div>
37<div class="tab-pane" title="script.js">
38<pre class="prettyprint linenums" ng-set-text="script.js-120"></pre>
39<script type="text/ng-template" id="script.js-120">
40   function Ctrl($scope) {
41     $scope.list = [];
42     $scope.text = 'hello';
43     $scope.submit = function() {
44       if (this.text) {
45         this.list.push(this.text);
46         this.text = '';
47       }
48     };
49   }
50 </script>
51</div>
52<div class="tab-pane" title="End to end test">
53<pre class="prettyprint linenums" ng-set-text="scenario.js-122"></pre>
54<script type="text/ng-template" id="scenario.js-122">
55  it('should check ng-submit', function() {
56    expect(binding('list')).toBe('[]');
57    element('.doc-example-live #submit').click();
58    expect(binding('list')).toBe('["hello"]');
59    expect(input('text').val()).toBe('');
60  });
61  it('should ignore empty strings', function() {
62    expect(binding('list')).toBe('[]');
63    element('.doc-example-live #submit').click();
64    element('.doc-example-live #submit').click();
65    expect(binding('list')).toBe('["hello"]');
66  });
67</script>
68</div>
69</div><h4>Demo</h4>
70<div class="well doc-example-live" ng-embed-app="" ng-set-html="index.html-121" ng-eval-javascript="script.js-120"></div></div>
71</div>