docs(aio): Update `NgStyle` and `NgClass` to use quoted keys
This commit is contained in:
parent
9c1f6fd06f
commit
0ede642cb9
|
@ -14,13 +14,13 @@
|
||||||
<h1>Example Snippets</h1>
|
<h1>Example Snippets</h1>
|
||||||
|
|
||||||
<!-- #docregion ngClass -->
|
<!-- #docregion ngClass -->
|
||||||
<div [ngClass]="{active: isActive}">
|
<div [ngClass]="{'active': isActive}">
|
||||||
<!-- #enddocregion ngClass -->
|
<!-- #enddocregion ngClass -->
|
||||||
[ngClass] active
|
[ngClass] active
|
||||||
</div>
|
</div>
|
||||||
<!-- #docregion ngClass -->
|
<!-- #docregion ngClass -->
|
||||||
<div [ngClass]="{active: isActive,
|
<div [ngClass]="{'active': isActive,
|
||||||
shazam: isImportant}">
|
'shazam': isImportant}">
|
||||||
<!-- #enddocregion ngClass -->
|
<!-- #enddocregion ngClass -->
|
||||||
[ngClass] active and boldly important
|
[ngClass] active and boldly important
|
||||||
</div>
|
</div>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
|
|
||||||
<p></p>
|
<p></p>
|
||||||
<!-- #docregion ngStyle -->
|
<!-- #docregion ngStyle -->
|
||||||
<div [ngStyle]="{color: colorPreference}">
|
<div [ngStyle]="{'color': colorPreference}">
|
||||||
<!-- #enddocregion ngStyle -->
|
<!-- #enddocregion ngStyle -->
|
||||||
color preference #1
|
color preference #1
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -213,10 +213,10 @@
|
||||||
<h2 id="myUnless">UnlessDirective</h2>
|
<h2 id="myUnless">UnlessDirective</h2>
|
||||||
<p>
|
<p>
|
||||||
The condition is currently
|
The condition is currently
|
||||||
<span [ngClass]="{ a: !condition, b: condition, unless: true }">{{condition}}</span>.
|
<span [ngClass]="{ 'a': !condition, 'b': condition, 'unless': true }">{{condition}}</span>.
|
||||||
<button
|
<button
|
||||||
(click)="condition = !condition"
|
(click)="condition = !condition"
|
||||||
[ngClass] = "{ a: condition, b: !condition }" >
|
[ngClass] = "{ 'a': condition, 'b': !condition }" >
|
||||||
Toggle condition to {{condition ? 'false' : 'true'}}
|
Toggle condition to {{condition ? 'false' : 'true'}}
|
||||||
</button>
|
</button>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -161,7 +161,7 @@
|
||||||
<!-- #docregion property-binding-syntax-1 -->
|
<!-- #docregion property-binding-syntax-1 -->
|
||||||
<img [src]="heroImageUrl">
|
<img [src]="heroImageUrl">
|
||||||
<hero-detail [hero]="currentHero"></hero-detail>
|
<hero-detail [hero]="currentHero"></hero-detail>
|
||||||
<div [ngClass]="{special: isSpecial}"></div>
|
<div [ngClass]="{'special': isSpecial}"></div>
|
||||||
<!-- #enddocregion property-binding-syntax-1 -->
|
<!-- #enddocregion property-binding-syntax-1 -->
|
||||||
</div>
|
</div>
|
||||||
<br><br>
|
<br><br>
|
||||||
|
@ -496,7 +496,7 @@ bindon-ngModel
|
||||||
<div [ngClass]="isSpecial ? 'special' : ''">This div is special</div>
|
<div [ngClass]="isSpecial ? 'special' : ''">This div is special</div>
|
||||||
|
|
||||||
<div class="bad curly special">Bad curly special</div>
|
<div class="bad curly special">Bad curly special</div>
|
||||||
<div [ngClass]="{bad:false, curly:true, special:true}">Curly special</div>
|
<div [ngClass]="{'bad':false, 'curly':true, 'special':true}">Curly special</div>
|
||||||
|
|
||||||
<a class="to-toc" href="#toc">top</a>
|
<a class="to-toc" href="#toc">top</a>
|
||||||
|
|
||||||
|
|
|
@ -140,9 +140,9 @@ export class AppComponent implements AfterViewInit, OnInit {
|
||||||
setCurrentClasses() {
|
setCurrentClasses() {
|
||||||
// CSS classes: added/removed per current state of component properties
|
// CSS classes: added/removed per current state of component properties
|
||||||
this.currentClasses = {
|
this.currentClasses = {
|
||||||
saveable: this.canSave,
|
'saveable': this.canSave,
|
||||||
modified: !this.isUnchanged,
|
'modified': !this.isUnchanged,
|
||||||
special: this.isSpecial
|
'special': this.isSpecial
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// #enddocregion setClasses
|
// #enddocregion setClasses
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div *ngIf="phone">
|
<div *ngIf="phone">
|
||||||
<div class="phone-images">
|
<div class="phone-images">
|
||||||
<img [src]="img" class="phone"
|
<img [src]="img" class="phone"
|
||||||
[ngClass]="{selected: img === mainImageUrl}"
|
[ngClass]="{'selected': img === mainImageUrl}"
|
||||||
*ngFor="let img of phone.images" />
|
*ngFor="let img of phone.images" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<div *ngIf="phone">
|
<div *ngIf="phone">
|
||||||
<div class="phone-images">
|
<div class="phone-images">
|
||||||
<img [src]="img" class="phone"
|
<img [src]="img" class="phone"
|
||||||
[ngClass]="{selected: img === mainImageUrl}"
|
[ngClass]="{'selected': img === mainImageUrl}"
|
||||||
*ngFor="let img of phone.images" />
|
*ngFor="let img of phone.images" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -136,7 +136,7 @@ is available to <code>declarations</code> of this module.</p>
|
||||||
<td><p>Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of <code>conditionExpression</code>.</p>
|
<td><p>Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of <code>conditionExpression</code>.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr><tr>
|
</tr><tr>
|
||||||
<td><code><div <b>[ngClass]</b>="{active: isActive, disabled: isDisabled}"></code></td>
|
<td><code><div <b>[ngClass]</b>="{'active': isActive, 'disabled': isDisabled}"></code></td>
|
||||||
<td><p>Binds the presence of CSS classes on the element to the truthiness of the associated map values. The right-hand expression should return {class-name: true/false} map.</p>
|
<td><p>Binds the presence of CSS classes on the element to the truthiness of the associated map values. The right-hand expression should return {class-name: true/false} map.</p>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
|
@ -1371,7 +1371,7 @@ _This_ section is an introduction to the common structural directives:
|
||||||
### NgIf
|
### NgIf
|
||||||
|
|
||||||
You can add or remove an element from the DOM by applying an `NgIf` directive to
|
You can add or remove an element from the DOM by applying an `NgIf` directive to
|
||||||
that element (called the _host elment_).
|
that element (called the _host element_).
|
||||||
Bind the directive to a condition expression like `isActive` in this example.
|
Bind the directive to a condition expression like `isActive` in this example.
|
||||||
|
|
||||||
<code-example path="template-syntax/src/app/app.component.html" region="NgIf-1" title="src/app/app.component.html" linenums="false">
|
<code-example path="template-syntax/src/app/app.component.html" region="NgIf-1" title="src/app/app.component.html" linenums="false">
|
||||||
|
|
Loading…
Reference in New Issue