码迷,mamicode.com
首页 > 其他好文 > 详细

Built-in Components

时间:2016-11-06 13:48:50      阅读:198      评论:0      收藏:0      [点我收藏+]

标签:end   item   component   image   技术   bin   .com   pre   header   

 

NgIF

1 <div *ngIf="false"></div> <!-- never displayed -->
2 <div *ngIf="a > b"></div> <!-- displayed if a is more than b -->
3 <div *ngIf="str == ‘yes‘"></div> <!-- displayed if str holds the string "yes" -->
5 <div *ngIf="myFunc()"></div> <!-- displayed if myFunc returns a true value -->

NgSwitch

<div class="container" [ngSwitch]="myVar">
    <div *ngSwitchCase="‘A‘">Var is A</div>
    <div *ngSwitchCase="‘B‘">Var is B</div>
    <div *ngSwitchDefault>Var is something else</div>
</div>

NgStyle

<div>
    <span [ngStyle]="{color: ‘red‘}" [style.font-size.px]="fontSize">
        red text
    </span>
</div>

NgClass

<div [ngClass]="classesObj">
    Using object var. Border {{ classesObj.bordered ? "ON" : "OFF" }}
</div>

NgFor

<h4 class="ui horizontal divider header">
    Simple list of strings
</h4>

<div class="ui list" *ngFor="let c of cities">
    <div class="item">{{ c }}</div>
</div>

Geting an index

<div class="ui list" *ngFor="let c of cities; let num = index">
    <div class="item">{{ num+1 }} - {{ c }}</div>
</div>

 

NgNonBindable

1 <div class=‘ngNonBindableDemo‘>
2     <span class="bordered">{{ content }}</span>
3     <span class="pre" ngNonBindable>
4          This is what {{ content }} rendered
5     </span>
6 </div>    

技术分享

 

Built-in Components

标签:end   item   component   image   技术   bin   .com   pre   header   

原文地址:http://www.cnblogs.com/fangshiwei/p/6035096.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!