作者: | 来源:互联网 | 2023-12-09 09:29
1.第一步把依赖添加到项目中
npm install primeng --save
npm install @angular/animations --save
npm install font-awesome@4.7.0 --save
2.在.angular-cli.json中添加
"styles": [
"styles.css",
"../node_modules/primeng/resources/primeng.min.css",
"../node_modules/primeng/resources/themes/omega/theme.css",
"../node_modules/font-awesome/css/font-awesome.min.css"
],
3.在app.module.ts中添加以下模块
import { BrowserModule } from '@angular/platform-browser';
ButtonModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
4.在app.component.ts中添加
import {Component} from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor( ) { }
name: string;
message: string;
onClick() {
this.message = "Hello , " + this.name;
}
}
5.在app.component.html中添加
{{message}}
测试结果: