zoukankan      html  css  js  c++  java
  • Angular4.0--创建类实例

    src/app/hero.ts文件:

    export class Hero {
      constructor(
        public id: number,
        public name: string) { }
    }

    src/app/app.component.ts文件:

    import { Component } from '@angular/core';
    import { Hero } from './hero';
    
    
    @Component({
      selector: 'my-app',
      template: `{{title}}My favorite hero is:{{myHero.name}}Heroes:{{ hero.name }}There are many heroes!`
    })
    
    export class AppComponent {
      title = 'Tour of Heroes';
      heroes = [
        new Hero(1, 'Windstorm'),
        new Hero(13, 'Bombasto'),
        new Hero(15, 'Magneta'),
        new Hero(20, 'Tornado')
      ];
      myHero = this.heroes[0];
    }
  • 相关阅读:
    selenium 难定位元素、时间插件
    列表生成式
    三元表达式
    监控日志
    非空即真
    深拷贝浅拷贝
    元组
    list字典嵌套
    2021
    布尔类型
  • 原文地址:https://www.cnblogs.com/xuepei/p/7520009.html
Copyright © 2011-2022 走看看