首页 > 其他 > 详细

显示数据

时间:2020-10-10 12:13:17      阅读:20      评论:0      收藏:0      [点我收藏+]

显示数据

ng的模版中,默认用双大括号{{}}绑定组件中的变量显示出来

import { Component } from ‘@angular/core‘;
@Component({
  selector: ‘app-root‘,
  template: `
    <h1>{{title}}</h1>
    <h2>My favorite hero is: {{myHero}}</h2>
    `,
  styles: [`h1 { color: red }`]
})
export class AppComponent {
  title = ‘Tour of Heroes‘;
  myHero = ‘Windstorm‘;
}

 

模板来源

ng的模版和样式可以是内联(上述示例),也可以是单独的文件

import { Component } from ‘@angular/core‘;
@Component({
  selector: ‘app-root‘,
  templateUrl: ‘./app.component.html‘,
  styleUrls: [‘./app.component.scss‘]
})
export class AppComponent {
  title = ‘Tour of Heroes‘;
  myHero = ‘Windstorm‘;
}

 

 

模板中的 HTML

大部分html标签都能在模版中使用,但有一些是毫无意义的:
html body script base

显示数据

原文:https://www.cnblogs.com/jahoon/p/13790257.html

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