美文网首页
教程二——数据

教程二——数据

作者: lmmy123 | 来源:发表于2017-12-06 17:21 被阅读7次

    1.使用插值表达式显示组件属性

    <h1>hello {{ name }}</h1>

    2.内联(inline)模板还是模板文件?

    template: `

        <h1>{{ name }}</h1>

      `

    模板文件:@Component装饰器中的templateUrl属性,在组件元数据中把它链接到组件


    3.使用 ngFor显示数组属性

    <ul>

    <li *ngFor="let hero of heros>

        {{ hero }}

    </li>

    </ul>

    4.使用ngIf进行条件显示

    <p *ngIf="heroes.length > 3">圣诞节覅是</p>

    相关文章

      网友评论

          本文标题:教程二——数据

          本文链接:https://www.haomeiwen.com/subject/erhlixtx.html