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';

import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import {FormsModule} from "@angular/forms";
import {HttpModule} from "@angular/http";
import {BrowserAnimationsModule} from "@angular/platform-browser/animations";
import {ButtonModule, InputTextModule} from "primeng/primeng"; @NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
FormsModule,
HttpModule,
BrowserAnimationsModule,
InputTextModule,
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中添加
<input type="text" [(ngModel)]="name" pInputText>

<button type="button" pButton label="Click" icon="fa fa-check" (click)="onClick($event)"></button>

<div>{{message}}</div>
测试结果:








												

angular项目中使用Primeng的更多相关文章

  1. gulp 在 angular 项目中的使用

    gulp 在 angular 项目中的使用 keyword:gulp,angularjs,ng,ngAnnotate,jshint,gulpfile 最后附完整简洁的ng项目gulpfile.js 准 ...

  2. angular项目中各个文件的作用

    原文地址 https://www.jianshu.com/p/176ea79a7101 大纲 1.对angular项目中的一些文件的概述 2.对其中一些文件的详细描述 2.1.package.json ...

  3. Angular 项目中如何使用 ECharts

    在有些使用 ECharts 库的 Angular 项目中,通常除了安装 npm 包之外,还会在 angular.json 中配置 “build.options.scripts”,将 “node_mod ...

  4. angular项目中遇到的问题

    一.angular项目中如何实现路由缓存 需要实现的效果,对请求的数据进行缓存,比如进入文章详情页之后点击返回,不会再调用后台数据接口:而是加载缓存中的数据,如何数据变动的情况下,可使用下拉刷新刷新页 ...

  5. Angular项目中引入jQuery

    npm install --save jquery npm install @types/jquery --save 在对应的组件中引入 import * as $ from "jquery ...

  6. 在angular项目中使用bootstrap的tooltip插件时,报错Property 'tooltip' does no t exist on type 'JQuery<HTMLElement>的解决方法和过程

    在angular4的项目中需要使用bootstrap的tooltip插件. 1. 使用命令安装jQuery和bootstrap npm install bootstrap jquery --save ...

  7. angular项目中使用jquery的问题

    1.使用npm命令往项目中添加jQuery. npm install jquery --save 2.在你想要用jQuery的组件中添加. import * as $ from "jquer ...

  8. Angular项目中共享模块的实现

    创建share Modele:ng g m share import进来所有需要共享的模块都export出去, 一.共享CommonModule 暂时只有CommonModule,以后会有一些需要共享 ...

  9. Angular项目中核心模块core Module只加载一次的实现

    核心模块CoreModule在整个系统中只加载一次,如何实现? 创建core Modele:ng g m core 既然CoreModule是类,就有构造函数,在构造函数中进行依赖注入. export ...

随机推荐

  1. Codeforces Round#514 Div.2 翻车记

    A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...

  2. 3.7 TCP拥塞控制

    3.7 TCP拥塞控制 在3.5.5流量控制中有,接收方通过维护一个rwnd来控制流量,本节中考虑三个问题: 第一,  一个TCP发送方如何限制它向其他连接发送流量的速率. 第二,  一个TCP发送方 ...

  3. bzoj3173

    Description 给定一个序列,初始为空.现在我们将1到N的数字插入到序列中,每次将一个数字插入到一个特定的位置.每插入一个数字,我们都想知道此时最长上升子序列长度是多少? Input 第一行一 ...

  4. 把lighttpd配置为系统服务

    每次启动切换到 /usr/local/lighttpd/sbin 执行 ./lighttpd -f /usr/local/lighttpd/lighttpd.conf 比较麻烦, 而且不方便重新启动! ...

  5. 在 Xamarin.Forms 实现页面全屏显示

    NavigationPage.SetHasNavigationBar(this, false); 或者 <ContentPage ... NavigationPage.HasNavigation ...

  6. 【cdq分治】【CF1093E】 Intersection of Permutations

    传送门 果然前两天写完咕咕咕那个题的题解以后博客就开始咕咕咕了-- Description 给定整数 \(n\) 和两个 \(1~\sim~n\) 的排列 \(A,B\). \(m\) 个操作,操作有 ...

  7. PID控制算法的C语言实现五 积分分离的PID控制算法C语言实现

    在普通PID控制中,引入积分环节的目的主要是为了消除静差,提高控制精度.但在过程的启动.结束或大幅度增减设定时,短时间内系统输出有很大的偏差,会造成PID运算的积分积累,致使控制量超过执行机构可能允许 ...

  8. 「七天自制PHP框架」第一天:路由与控制器

    我们为什么要使用路由? 原因1:一个更漂亮的URI 1.URI的改进 刚刚开始学PHP时,我们一定写过blog.php?id=1之类的URI,使用GET方式获取参数.这样的URI有两个缺点,一是容易被 ...

  9. My deep learning reading list

    My deep learning reading list 主要是顺着Bengio的PAMI review的文章找出来的.包括几本综述文章,将近100篇论文,各位山头们的Presentation.全部 ...

  10. 搭建Elasticsearch5.6.8 分布式集群

    集群搭建 1.master[192.168.101.175] 配置elasticsearch.yml #集群名称 所有节点要相同 cluster.name: my-application #本节点名称 ...