forked from angular/code.angularjs.org
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathangular.directive.ng:class.html
45 lines (43 loc) · 1.45 KB
/
angular.directive.ng:class.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<h1>angular.directive.ng:class</h1>
<fieldset class="workInProgress">
<legend>Work In Progress</legend>
This page is currently being revised. It might be incomplete or contain inaccuracies.
</fieldset>
<h2>Description</h2>
<p>The <code>ng:class</code> allows you to set CSS class on HTML element
conditionally.</p>
<h2>Usage</h2>
<h3>In HTML Template Binding</h3>
<tt>
<pre>
<ANY ng:class="expression">
...
</ANY>
</pre>
</tt>
<h3>Parameters</h3>
<ul>
<li><tt>expression</tt> –
<tt>{expression}</tt>
<tt></tt>
– to eval.</li>
</ul>
<h2>Example</h2>
<doc:example>
<doc:source>
<input type="button" value="set" ng:click="myVar='ng-input-indicator-wait'">
<input type="button" value="clear" ng:click="myVar=''">
<br>
<span ng:class="myVar">Sample Text &nbsp;&nbsp;&nbsp;&nbsp;</span>
</doc:source>
<doc:scenario> it('should check ng:class', function(){
expect(element('.doc-example-live span').attr('className')).not().
toMatch(/ng-input-indicator-wait/);
using('.doc-example-live').element(':button:first').click();
expect(element('.doc-example-live span').attr('className')).
toMatch(/ng-input-indicator-wait/);
using('.doc-example-live').element(':button:last').click();
expect(element('.doc-example-live span').attr('className')).not().
toMatch(/ng-input-indicator-wait/);
});</doc:scenario>
</doc:example>