1.1.5Angular2常用组件

 

demo

<select name="" id="" class="form-control" 
    [(ngModel)]="branchInsuranceCompanyId"
    (ngModelChange)="changeCompany()">
    <option [value]="insuraceCompany.id" *ngFor="let insuraceCompany of insuraceCompanyList"> {{insuraceCompany.insurerName}}  </option>

    <!-- <option value=""></option> -->
</select>
<btton class="btn btn-primary" type="button" (click)="getInjuryBasePriceList()">
    <i class="fa"></i>收索
</btton>

 

angular2常用组件

更多参见

http://www.cnblogs.com/1wen/p/5564368.html

 

功能

代码参考

{{属性名}}

数据绑定对象

{{insuraceCompany.insurerName}}

(click)

标签的点击事件

(click)="getInjuryBasePriceList()"

[(ngModel)]

数据双向绑定

[(ngModel)]="branchInsuranceCompanyId"

*ngFor

循环

*ngFor="let insuraceCompany of insuraceCompanyList"

*ngIf

<table *ngIf="movies.length">

 

 

ngModelChange

selectchange事件

(ngModelChange)="changeCompany()"

[value]

selectoption value事件

[value]="insuraceCompany.id"

[hidden]

<h3 [hidden]="!favoriteHero">

  Your favorite hero is: {{favoriteHero}}</h3>

 

ngClass/ngStyle

页面添加样式控制

[ngStyle]="{color: colorPreference}"

[style.color]="colorPreference"

 

ngSwitch

页面条件控制(状态控制)

<span [ngSwitch]="favoriteHero">

  <p *ngSwitchWhen="true">

    Excellent choice!

  </p>

  <p *ngSwitchWhen="false">

    No movie, sorry!

  </p>

  <p *ngSwitchDefault>

    Please enter your favorite hero.

  </p>

</span>

posted @ 2017-08-23 16:30  alan-alan  阅读(239)  评论(0编辑  收藏  举报