首页 > 其他 > 详细

angular4-常用指令

时间:2017-09-01 09:30:47      阅读:297      评论:0      收藏:0      [点我收藏+]

ngIf 指令(它与 AngularJS 1.x 中的 ng-if 指令的功能是等价)

<div *ngIf="condition">...</div>

ngFor 指令(它与 AngularJS 1.x 中的 ng-repeat 指令的功能是等价的)

<li *ngFor="let item of items;">...</li>

 

ngIf 与 ngFor 指令使用示例

import { Component } from @angular/core;

@Component({
    selector: sl-user,
    template: `
    <div *ngIf="showSkills">
        <ul>
            <li *ngFor="let skill of skills">
                {{skill}}
            </li>
        </ul>
    </div>
    `
})
export class UserComponent {
    showSkills: boolean;
    skills: string[];

    constructor() {
        this.showSkills = true;
        this.skills = [AngularJS 1.x, Angular 2.x, Angular 4.x];
    }
}

 

angular4-常用指令

原文:http://www.cnblogs.com/avidya/p/7461312.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!