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>
|
||||
|
||||
<!-- #docregion ngClass -->
|
||||
<div [ngClass]="{active: isActive}">
|
||||
<div [ngClass]="{'active': isActive}">
|
||||
<!-- #enddocregion ngClass -->
|
||||
[ngClass] active
|
||||
</div>
|
||||
<!-- #docregion ngClass -->
|
||||
<div [ngClass]="{active: isActive,
|
||||
shazam: isImportant}">
|
||||
<div [ngClass]="{'active': isActive,
|
||||
'shazam': isImportant}">
|
||||
<!-- #enddocregion ngClass -->
|
||||
[ngClass] active and boldly important
|
||||
</div>
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
<p></p>
|
||||
<!-- #docregion ngStyle -->
|
||||
<div [ngStyle]="{color: colorPreference}">
|
||||
<div [ngStyle]="{'color': colorPreference}">
|
||||
<!-- #enddocregion ngStyle -->
|
||||
color preference #1
|
||||
</div>
|
||||
|
|
|
@ -213,10 +213,10 @@
|
|||
<h2 id="myUnless">UnlessDirective</h2>
|
||||
<p>
|
||||
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
|
||||
(click)="condition = !condition"
|
||||
[ngClass] = "{ a: condition, b: !condition }" >
|
||||
[ngClass] = "{ 'a': condition, 'b': !condition }" >
|
||||
Toggle condition to {{condition ? 'false' : 'true'}}
|
||||
</button>
|
||||
</p>
|
||||
|
|
|
@ -161,7 +161,7 @@
|
|||
<!-- #docregion property-binding-syntax-1 -->
|
||||
<img [src]="heroImageUrl">
|
||||
<hero-detail [hero]="currentHero"></hero-detail>
|
||||
<div [ngClass]="{special: isSpecial}"></div>
|
||||
<div [ngClass]="{'special': isSpecial}"></div>
|
||||
<!-- #enddocregion property-binding-syntax-1 -->
|
||||
</div>
|
||||
<br><br>
|
||||
|
@ -496,7 +496,7 @@ bindon-ngModel
|
|||
<div [ngClass]="isSpecial ? 'special' : ''">This div is 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>
|
||||
|
||||
|
|
|
@ -140,9 +140,9 @@ export class AppComponent implements AfterViewInit, OnInit {
|
|||
setCurrentClasses() {
|
||||
// CSS classes: added/removed per current state of component properties
|
||||
this.currentClasses = {
|
||||
saveable: this.canSave,
|
||||
modified: !this.isUnchanged,
|
||||
special: this.isSpecial
|
||||
'saveable': this.canSave,
|
||||
'modified': !this.isUnchanged,
|
||||
'special': this.isSpecial
|
||||
};
|
||||
}
|
||||
// #enddocregion setClasses
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div *ngIf="phone">
|
||||
<div class="phone-images">
|
||||
<img [src]="img" class="phone"
|
||||
[ngClass]="{selected: img === mainImageUrl}"
|
||||
[ngClass]="{'selected': img === mainImageUrl}"
|
||||
*ngFor="let img of phone.images" />
|
||||
</div>
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div *ngIf="phone">
|
||||
<div class="phone-images">
|
||||
<img [src]="img" class="phone"
|
||||
[ngClass]="{selected: img === mainImageUrl}"
|
||||
[ngClass]="{'selected': img === mainImageUrl}"
|
||||
*ngFor="let img of phone.images" />
|
||||
</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>
|
||||
</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>
|
||||
</tr>
|
||||
|
|
|
@ -1371,7 +1371,7 @@ _This_ section is an introduction to the common structural directives:
|
|||
### NgIf
|
||||
|
||||
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.
|
||||
|
||||
<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