2015-11-05 07:33:56 -05:00
@cheatsheetSection
2015-11-06 07:26:24 -05:00
Built-in directives
2015-11-13 02:14:12 -05:00
@cheatsheetIndex 2
2015-11-05 07:33:56 -05:00
@description
`import {NgIf, ...} from 'angular2/angular2';`
@cheatsheetItem
2015-12-09 07:33:42 -05:00
syntax:
2015-11-05 07:33:56 -05:00
`<section *ng-if="showSection">` |`*ng-if`
2015-12-09 07:33:42 -05:00
description:
2015-11-05 07:33:56 -05:00
Removes or recreates a portion of the DOM tree based on the showSection expression.
@cheatsheetItem
2015-12-09 07:33:42 -05:00
syntax:
2015-11-05 07:33:56 -05:00
`<li *ng-for="#item of list">` |`*ng-for`
2015-12-09 07:33:42 -05:00
description:
2015-11-05 07:33:56 -05:00
Turns the li element and its contents into a template, and uses that to instantiate a view for each item in list.
@cheatsheetItem
2015-12-09 07:33:42 -05:00
syntax:
2015-11-05 07:33:56 -05:00
`< div [ ng-switch ] = " conditionExpression " >
< template [ ng-switch-when ] = " case1Exp " > ...< / template >
< template ng-switch-when = "case2LiteralString" > ...< / template >
< template ng-switch-default > ...< / template >
< / div > `|`[ng-switch]`|`[ng-switch-when]`|`ng-switch-when`|`ng-switch-default`
2015-12-09 07:33:42 -05:00
description:
2015-11-05 07:33:56 -05:00
Conditionally swaps the contents of the div by selecting one of the embedded templates based on the current value of conditionExpression.
@cheatsheetItem
2015-12-09 07:33:42 -05:00
syntax:
2015-11-05 07:33:56 -05:00
`<div [ng-class]="{active: isActive, disabled: isDisabled}">` |`[ng-class]`
2015-12-09 07:33:42 -05:00
description:
2015-11-05 07:33:56 -05:00
Binds the presence of css classes on the element to the truthiness of the associated map values. The right-hand side expression should return {class-name: true/false} map.