Update to Angular 1.1.4
This commit is contained in:
parent
72a485d6e8
commit
f5fc1369ad
585 changed files with 48055 additions and 3041 deletions
117
lib/angular/docs/partials/api/ng.directive:ngSwitch.html
Normal file → Executable file
117
lib/angular/docs/partials/api/ng.directive:ngSwitch.html
Normal file → Executable file
|
@ -2,15 +2,29 @@
|
|||
<span class="hint">(directive in module <code ng:non-bindable="">ng</code>
|
||||
)</span>
|
||||
</h1>
|
||||
<div><h2 id="Description">Description</h2>
|
||||
<div class="description"><p>Conditionally change the DOM structure.</p></div>
|
||||
<div><a href="http://github.com/angular/angular.js/edit/master/src/ng/directive/ngSwitch.js" class="improve-docs btn btn-primary">Improve this doc</a><h2 id="Description">Description</h2>
|
||||
<div class="description"><p>The ngSwitch directive is used to conditionally swap DOM structure on your template based on a scope expression.
|
||||
Elements within ngSwitch but without ngSwitchWhen or ngSwitchDefault directives will be preserved at the location
|
||||
as specified in the template.</p>
|
||||
|
||||
<p>The directive itself works similar to ngInclude, however, instead of downloading template code (or loading it
|
||||
from the template cache), ngSwitch simply choses one of the nested elements and makes it visible based on which element
|
||||
matches the value obtained from the evaluated expression. In other words, you define a container element
|
||||
(where you place the directive), place an expression on the <strong>on="..." attribute</strong>
|
||||
(or the <strong>ng-switch="..." attribute</strong>), define any inner elements inside of the directive and place
|
||||
a when attribute per element. The when attribute is used to inform ngSwitch which element to display when the on
|
||||
expression is evaluated. If a matching expression is not found via a when attribute then an element with the default
|
||||
attribute is displayed.</p>
|
||||
|
||||
<p>Additionally, you can also provide animations via the ngAnimate attribute to animate the <strong>enter</strong>
|
||||
and <strong>leave</strong> effects.</p></div>
|
||||
<h2 id="Usage">Usage</h2>
|
||||
<div class="usage">as element (see <a href="guide/ie">IE restrictions</a>)<pre class="prettyprint linenums"><ng-switch
|
||||
on="{*}">
|
||||
</ng-switch></pre>
|
||||
as attribute<pre class="prettyprint linenums"><ANY ng-switch="{*}">
|
||||
...
|
||||
</ANY></pre>
|
||||
<div class="usage"><p>This directive can be used as custom element, but we aware of <a href="guide/ie">IE restrictions</a>.</p><pre><code ng:non-bindable=""><ANY ng-switch="expression">
|
||||
<ANY ng-switch-when="matchValue1">...</ANY>
|
||||
<ANY ng-switch-when="matchValue2">...</ANY>
|
||||
<ANY ng-switch-default>...</ANY>
|
||||
</ANY></code>
|
||||
</pre>
|
||||
<h3 id="Directive.info">Directive info</h3>
|
||||
<div class="directive-info"><ul><li>This directive creates new scope.</li>
|
||||
</ul>
|
||||
|
@ -19,52 +33,93 @@ as attribute<pre class="prettyprint linenums"><ANY ng-switch="{*}">
|
|||
<ul class="parameters"><li><code ng:non-bindable="">ngSwitch|on – {*} – </code>
|
||||
<p>expression to match against <tt>ng-switch-when</tt>.</p></li>
|
||||
</ul>
|
||||
<h3 id="Animations">Animations</h3>
|
||||
<div class="animations"><ul><li>enter - happens after the ngSwtich contents change and the matched child element is placed inside the container</li><li>leave - happens just after the ngSwitch contents change and just before the former contents are removed from the DOM</li></ul></div>
|
||||
</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-179" source-edit-css="" source-edit-js="script.js-178" source-edit-unit="" source-edit-scenario="scenario.js-180"></div>
|
||||
<div source-edit="" source-edit-deps="angular.js script.js" source-edit-html="index.html-178" source-edit-css="animations.css" source-edit-js="script.js-179" source-edit-unit="" source-edit-scenario="scenario.js-180"></div>
|
||||
<div class="tabbable"><div class="tab-pane" title="index.html">
|
||||
<pre class="prettyprint linenums" ng-set-text="index.html-179" ng-html-wrap=" angular.js script.js"></pre>
|
||||
<script type="text/ng-template" id="index.html-179">
|
||||
|
||||
<pre class="prettyprint linenums" ng-set-text="index.html-178" ng-html-wrap=" angular.js script.js"></pre>
|
||||
<script type="text/ng-template" id="index.html-178">
|
||||
<div ng-controller="Ctrl">
|
||||
<select ng-model="selection" ng-options="item for item in items">
|
||||
</select>
|
||||
<tt>selection={{selection}}</tt>
|
||||
<hr/>
|
||||
<div ng-switch on="selection" >
|
||||
<div ng-switch-when="settings">Settings Div</div>
|
||||
<span ng-switch-when="home">Home Span</span>
|
||||
<span ng-switch-default>default</span>
|
||||
<div
|
||||
class="example-animate-container"
|
||||
ng-switch on="selection"
|
||||
ng-animate="{enter: 'example-enter', leave: 'example-leave'}">
|
||||
<div ng-switch-when="settings">Settings Div</div>
|
||||
<div ng-switch-when="home">Home Span</div>
|
||||
<div ng-switch-default>default</div>
|
||||
</div>
|
||||
</div>
|
||||
</script>
|
||||
</div>
|
||||
<div class="tab-pane" title="animations.css">
|
||||
<pre class="prettyprint linenums" ng-set-text="animations.css"></pre>
|
||||
<style type="text/css" id="animations.css">
|
||||
.example-leave-setup, .example-enter-setup {
|
||||
-webkit-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
|
||||
-moz-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
|
||||
-ms-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
|
||||
-o-transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
|
||||
transition:all cubic-bezier(0.250, 0.460, 0.450, 0.940) 0.5s;
|
||||
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
right:0;
|
||||
bottom:0;
|
||||
}
|
||||
|
||||
.example-animate-container > * {
|
||||
display:block;
|
||||
padding:10px;
|
||||
}
|
||||
|
||||
.example-enter-setup {
|
||||
top:-50px;
|
||||
}
|
||||
.example-enter-start.example-enter-start {
|
||||
top:0;
|
||||
}
|
||||
|
||||
.example-leave-setup {
|
||||
top:0;
|
||||
}
|
||||
.example-leave-start.example-leave-start {
|
||||
top:50px;
|
||||
}
|
||||
</style>
|
||||
</div>
|
||||
<div class="tab-pane" title="script.js">
|
||||
<pre class="prettyprint linenums" ng-set-text="script.js-178"></pre>
|
||||
<script type="text/ng-template" id="script.js-178">
|
||||
function Ctrl($scope) {
|
||||
$scope.items = ['settings', 'home', 'other'];
|
||||
$scope.selection = $scope.items[0];
|
||||
}
|
||||
</script>
|
||||
<pre class="prettyprint linenums" ng-set-text="script.js-179"></pre>
|
||||
<script type="text/ng-template" id="script.js-179">
|
||||
function Ctrl($scope) {
|
||||
$scope.items = ['settings', 'home', 'other'];
|
||||
$scope.selection = $scope.items[0];
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
<div class="tab-pane" title="End to end test">
|
||||
<pre class="prettyprint linenums" ng-set-text="scenario.js-180"></pre>
|
||||
<script type="text/ng-template" id="scenario.js-180">
|
||||
it('should start in settings', function() {
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Settings Div/);
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Settings Div/);
|
||||
});
|
||||
it('should change to home', function() {
|
||||
select('selection').option('home');
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Home Span/);
|
||||
select('selection').option('home');
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/Home Span/);
|
||||
});
|
||||
it('should select deafault', function() {
|
||||
select('selection').option('other');
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/default/);
|
||||
it('should select default', function() {
|
||||
select('selection').option('other');
|
||||
expect(element('.doc-example-live [ng-switch]').text()).toMatch(/default/);
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
</div><h4>Demo</h4>
|
||||
<div class="well doc-example-live" ng-embed-app="" ng-set-html="index.html-179" ng-eval-javascript="script.js-178"></div></div>
|
||||
</div><div class="pull-right"> <button class="btn btn-primary" ng-click="animationsOff=true" ng-hide="animationsOff">Animations on</button> <button class="btn btn-primary disabled" ng-click="animationsOff=false" ng-show="animationsOff">Animations off</button></div><h4>Demo</h4>
|
||||
<div class="well doc-example-live animator-container" ng-class="{'animations-off':animationsOff == true}" ng-embed-app="" ng-set-html="index.html-178" ng-eval-javascript="script.js-179"></div></div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue