Upgrade to angularjs 1.2.0 rc1
This commit is contained in:
parent
d223dfd662
commit
d6b021bfaf
674 changed files with 79667 additions and 62269 deletions
66
lib/angular/docs/partials/api/ng.directive:form.html
Normal file → Executable file
66
lib/angular/docs/partials/api/ng.directive:form.html
Normal file → Executable file
|
@ -1,77 +1,64 @@
|
|||
<h1><code ng:non-bindable="">form</code>
|
||||
<span class="hint">(directive in module <code ng:non-bindable="">ng</code>
|
||||
)</span>
|
||||
<a href="http://github.com/angular/angular.js/tree/v1.2.0rc1/src/ng/directive/form.js#L211" class="view-source btn btn-action"><i class="icon-zoom-in"> </i> View source</a><a href="http://github.com/angular/angular.js/edit/master/src/ng/directive/form.js" class="improve-docs btn btn-primary"><i class="icon-edit"> </i> Improve this doc</a><h1><code ng:non-bindable="">form</code>
|
||||
<div><span class="hint">directive in module <code ng:non-bindable="">ng</code>
|
||||
</span>
|
||||
</div>
|
||||
</h1>
|
||||
<div><a href="http://github.com/angular/angular.js/edit/master/src/ng/directive/form.js" class="improve-docs btn btn-primary">Improve this doc</a><h2 id="Description">Description</h2>
|
||||
<div class="description"><p>Directive that instantiates
|
||||
<div><h2 id="Description">Description</h2>
|
||||
<div class="description"><div class="ng-directive-page ng-directive-form-page"><p>Directive that instantiates
|
||||
<a href="api/ng.directive:form.FormController"><code>FormController</code></a>.</p>
|
||||
|
||||
<p>If <code>name</code> attribute is specified, the form controller is published onto the current scope under
|
||||
this name.</p>
|
||||
|
||||
<h3>Alias: <a href="api/ng.directive:ngForm"><code><code>ngForm</code></code></a></h3>
|
||||
|
||||
<h3>Alias: <a href="api/ng.directive:ngForm"><code><code>ngForm</code></code></a></h1>
|
||||
<p>In angular forms can be nested. This means that the outer form is valid when all of the child
|
||||
forms are valid as well. However browsers do not allow nesting of <code><form></code> elements, for this
|
||||
reason angular provides <a href="api/ng.directive:ngForm"><code><code>ngForm</code></code></a> alias
|
||||
which behaves identical to <code><form></code> but allows form nesting.</p>
|
||||
|
||||
<h3>CSS classes</h3>
|
||||
|
||||
<h1>CSS classes</h1>
|
||||
<ul>
|
||||
<li><code>ng-valid</code> Is set if the form is valid.</li>
|
||||
<li><code>ng-invalid</code> Is set if the form is invalid.</li>
|
||||
<li><code>ng-pristine</code> Is set if the form is pristine.</li>
|
||||
<li><code>ng-dirty</code> Is set if the form is dirty.</li>
|
||||
</ul>
|
||||
|
||||
<h3>Submitting a form and preventing default action</h3>
|
||||
|
||||
<h1>Submitting a form and preventing default action</h3>
|
||||
<p>Since the role of forms in client-side Angular applications is different than in classical
|
||||
roundtrip apps, it is desirable for the browser not to translate the form submission into a full
|
||||
page reload that sends the data to the server. Instead some javascript logic should be triggered
|
||||
to handle the form submission in application specific way.</p>
|
||||
|
||||
<p>For this reason, Angular prevents the default action (form submission to the server) unless the
|
||||
<code><form></code> element has an <code>action</code> attribute specified.</p>
|
||||
|
||||
<p>You can use one of the following two ways to specify what javascript method should be called when
|
||||
a form is submitted:</p>
|
||||
|
||||
<ul>
|
||||
<li><a href="api/ng.directive:ngSubmit"><code>ngSubmit</code></a> directive on the form element</li>
|
||||
<li><a href="api/ng.directive:ngClick"><code>ngClick</code></a> directive on the first
|
||||
button or input field of type submit (input[type=submit])</li>
|
||||
</ul>
|
||||
|
||||
<p>To prevent double execution of the handler, use only one of ngSubmit or ngClick directives. This
|
||||
is because of the following form submission rules coming from the html spec:</p>
|
||||
|
||||
<ul>
|
||||
<li>If a form has only one input field then hitting enter in this field triggers form submit
|
||||
(<code>ngSubmit</code>)</li>
|
||||
<li>if a form has has 2+ input fields and no buttons or input[type=submit] then hitting enter
|
||||
doesn't trigger submit</li>
|
||||
doesn't trigger submit</li>
|
||||
<li>if a form has one or more input fields and one or more buttons or input[type=submit] then
|
||||
hitting enter in any of the input fields will trigger the click handler on the <em>first</em> button or
|
||||
input[type=submit] (<code>ngClick</code>) <em>and</em> a submit handler on the enclosing form (<code>ngSubmit</code>)</li>
|
||||
</ul></div>
|
||||
</ul>
|
||||
</div></div>
|
||||
<h2 id="Usage">Usage</h2>
|
||||
<div class="usage"><p>This directive can be used as custom element, but we aware of <a href="guide/ie">IE restrictions</a>.</p>as element:<pre class="prettyprint linenums"><form
|
||||
<div class="usage"><p>This directive can be used as custom element, but be aware of <a href="guide/ie">IE restrictions</a>.</p>as element:<pre class="prettyprint linenums"><form
|
||||
[name="{string}"]>
|
||||
</form></pre>
|
||||
<h3 id="Parameters">Parameters</h3>
|
||||
<ul class="parameters"><li><code ng:non-bindable="">name<i>(optional)</i> – {string=} – </code>
|
||||
<p>Name of the form. If specified, the form controller will be published into
|
||||
related scope, under this name.</p></li>
|
||||
</ul>
|
||||
</div>
|
||||
<h4 id="parameters">Parameters</h4><table class="variables-matrix table table-bordered table-striped"><thead><tr><th>Param</th><th>Type</th><th>Details</th></tr></thead><tbody><tr><td>name <div><em>(optional)</em></div></td><td><a href="" class="label type-hint type-hint-string">string</a></td><td><div class="ng-directive-page ng-directive-form-page"><p>Name of the form. If specified, the form controller will be published into
|
||||
related scope, under this name.</p>
|
||||
</div></td></tr></tbody></table></div>
|
||||
<h2 id="Example">Example</h2>
|
||||
<div class="example"><h4>Source</h4>
|
||||
<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-101" source-edit-css="" source-edit-js="script.js-100" source-edit-unit="" source-edit-scenario="scenario.js-102"></div>
|
||||
<div class="example"><div class="ng-directive-page ng-directive-form-page"><h4>Source</h2>
|
||||
<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-14" source-edit-css="" source-edit-js="script.js-13" source-edit-json="" source-edit-unit="" source-edit-scenario="scenario.js-15"></div>
|
||||
<div class="tabbable"><div class="tab-pane" title="index.html">
|
||||
<pre class="prettyprint linenums" ng-set-text="index.html-101" ng-html-wrap=" angular.js script.js"></pre>
|
||||
<script type="text/ng-template" id="index.html-101">
|
||||
<pre class="prettyprint linenums" ng-set-text="index.html-14" ng-html-wrap=" angular.js script.js"></pre>
|
||||
<script type="text/ng-template" id="index.html-14">
|
||||
|
||||
<form name="myForm" ng-controller="Ctrl">
|
||||
userType: <input name="input" ng-model="userType" required>
|
||||
|
@ -85,16 +72,16 @@ related scope, under this name.</p></li>
|
|||
</script>
|
||||
</div>
|
||||
<div class="tab-pane" title="script.js">
|
||||
<pre class="prettyprint linenums" ng-set-text="script.js-100"></pre>
|
||||
<script type="text/ng-template" id="script.js-100">
|
||||
<pre class="prettyprint linenums" ng-set-text="script.js-13"></pre>
|
||||
<script type="text/ng-template" id="script.js-13">
|
||||
function Ctrl($scope) {
|
||||
$scope.userType = 'guest';
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<div class="tab-pane" title="End to end test">
|
||||
<pre class="prettyprint linenums" ng-set-text="scenario.js-102"></pre>
|
||||
<script type="text/ng-template" id="scenario.js-102">
|
||||
<pre class="prettyprint linenums" ng-set-text="scenario.js-15"></pre>
|
||||
<script type="text/ng-template" id="scenario.js-15">
|
||||
it('should initialize to model', function() {
|
||||
expect(binding('userType')).toEqual('guest');
|
||||
expect(binding('myForm.input.$valid')).toEqual('true');
|
||||
|
@ -107,6 +94,7 @@ related scope, under this name.</p></li>
|
|||
});
|
||||
</script>
|
||||
</div>
|
||||
</div><h4>Demo</h4>
|
||||
<div class="well doc-example-live animator-container" ng-embed-app="" ng-set-html="index.html-101" ng-eval-javascript="script.js-100"></div></div>
|
||||
</div><h2>Demo</h4>
|
||||
<div class="well doc-example-live animate-container" ng-embed-app="" ng-set-html="index.html-14" ng-eval-javascript="script.js-13"></div>
|
||||
</div></div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue