zoukankan      html  css  js  c++  java
  • Angular2 How to Repeat a List

    1 import directive [For]

    import {Component, Template, bootstrap, For} from 'angular2/angular2';
    

      it is important

    2 define your list

    class MyApp {
    
        constructor() {
            this.myName = 'Jackey';
            this.myFriends = [
                {name: 'Jackey1', age: 25},
                {name: 'Jackey2', age: 26}
            ];
        }
    }
    

    3 repeat you list to UI

    @Template({
        inline: '<h1>{{myName}}</h1>' +
        '<ul>' +
        '<li *for="#friend of myFriends">{{friend.name}} {{friend.age}}</li>' +
        '</ul>',
        directives: [For]
    
    })
    

      USE *for="#xx of XXX" .. REMEMBER to inject [for] directive

    4 the whole page code:

    import {Component, Template, bootstrap, For} from 'angular2/angular2';
    
    @Component({
        selector: 'my-app'
    })
    
    @Template({
        inline: '<h1>{{myName}}</h1>' +
        '<ul>' +
        '<li *for="#friend of myFriends">{{friend.name}} {{friend.age}}</li>' +
        '</ul>',
        directives: [For]
    
    })
    
    class MyApp {
    
        constructor() {
            this.myName = 'Jackey';
            this.myFriends = [
                {name: 'Jackey1', age: 25},
                {name: 'Jackey2', age: 26}
            ];
        }
    }
    
    bootstrap(MyApp);
    

      

  • 相关阅读:
    .NET 第一天
    C# 多线程操作同一文件
    c# 进制转换-续
    C# 进制转化
    DevExpress.Utils.ToolTipLocation
    gridView 练习
    dashboard 数据绑定的时候 addTable 是视图
    gridLookUpEdit1
    gridview1 设置 内容居中 标题剧中
    LOOKupE
  • 原文地址:https://www.cnblogs.com/lihaozhou/p/4663024.html
Copyright © 2011-2022 走看看