码迷,mamicode.com
首页 > 其他好文 > 详细

Angular-component(组件)

时间:2018-03-05 18:20:59      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:code   模板   nbsp   css   私有   body   选择器   位置   angular   

在当前项目目录下,使用Angular-CLI生成一个组件:heroes

ng generate component heroes

 

 

//heroes.component.html
<p>
  heroes works!
</p>


//heroes.component.css

//heroes.component.ts
import { Component, OnInit } from ‘@angular/core‘;
//始终Component从Angular核心库中导入符号,并使用注释组件类。

//@Component
 是指定组件的Angular元数据的装饰器函数。
@Component({
 //组件的CSS元素选择器
  selector: ‘app-heroes‘,
 //组件模板文件的位置
  templateUrl: ‘./heroes.component.html‘,
 //组件的私有CSS样式的位置
  styleUrls: [‘./heroes.component.css‘]
})
export class HeroesComponent implements OnInit {

  constructor() { }

  ngOnInit() {
  }

}

 

  

 

Angular-component(组件)

标签:code   模板   nbsp   css   私有   body   选择器   位置   angular   

原文地址:https://www.cnblogs.com/cisum/p/8510154.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!