Built-in Components

Posted 龙心七号

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Built-in Components相关的知识,希望对你有一定的参考价值。

 

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的主要内容,如果未能解决你的问题,请参考以下文章

ReactJs 报错 Element type is invalid: expected a string (from built-in components) or a class/function

817. Linked List Components - LeetCode

Android 片段和活动

使用styled-components实现CSS in JS

Navigation Components popBackStack() 是不是保留 Fragment 状态?

使用Architecture Components构建的应用程序是否使其成为“MVVM”,如果是,应用程序的哪些部分与哪个MVVM层相关?