Angular的一些常用命令

cmd中创建项目:

ng new taskmgr -si --style=scss

//先不安装依赖,si 为skip install

material需要scss样式的特性

在某个目录下打开vscode:code .

安装依赖: cnpm install

自动创建组件:ng generate component MyComponent,

简写 ng g c MyComponent

创建组件的时候也可以带路径,比如:ng generate component mydir/MyComponent

ng g c core/header --spec=false 不生成对应的单元测试文件

ng g c shared/confirm-dialog -it -is --spec=false inline template inline style 创建内联式的模板

自动创建mudule: ng g m core

自动创建指令:ng g d MyDirective

自动创建服务:ng g s MyService

构建项目:ng build,如果你想构建最终的产品版本(进行优化,包压缩等),可以用 ng build –prod

启动开发服务器:ng serve

angular-cli文档

安装angular material

cnpm i --save @angular/material@2.0.0-beta.7

如何在你的项目里面引入开源组件库

以 PrimeNG 为例,首先在 package.json 里面定义好依赖:

"devDependencies": {

"primeng": "^4.1.3"

}

1、 安装

cd 你的项目目录

npm install primeng --save-dev

2、 配置angular-cli.json

omega是一种主题,还有很多主题,bootstrap等等......

"styles": [

"styles.css",

"../node_modules/primeng/resources/themes/omega/theme.css",

"../node_modules/primeng/resources/primeng.min.css",

"../node_modules/font-awesome/css/font-awesome.css"

],

需要注意的是系统中的所有小图标都使用font-awosome字体库,font-awosome.css是字体图标文件,需要安装

npm install font-awesome --save

3、使用,需要使用的组件,都要在app.module.ts中加载

// 载入primeng模块

import {AutoCompleteModule, TabViewModule, ButtonModule} from "primeng/primeng"

......

@NgModule({

declarations: [

AppComponent

],

imports: [

BrowserModule,

FormsModule,

HttpModule,

AutoCompleteModule,

ButtonModule,

TabViewModule

],

......

最新文章

  1. 一个小白App开发需要了解的基本技术
  2. 微信js-sdk注意事项
  3. jstack简单使用,定位死循环、线程阻塞、死锁等问题
  4. [leetcode] Min Stack @ Python
  5. win7和centos双系统安装
  6. [MODX] 1. Template *
  7. sublime text3的一些小技巧记录(配gif图)
  8. asp.net中Web使用Socket
  9. android 使用android.support.v7 添加ActionBar
  10. PHP读取EXCEL时写入数据乱码解决办法
  11. 安装m2eclipse
  12. HTML5初步了解
  13. 百度音乐flac 下载
  14. python笔记:#008#变量的命名
  15. mysql开发规范(优化)
  16. 聚类--K均值算法
  17. 13. nginx,lvs之一
  18. python自动化开发-[第十一天]-Mysql
  19. UIScrollView上面的UIButton点击始终在中间
  20. scrapy的Middleware

热门文章

  1. CSAW CTF Qualification Round 2018 - shell->code
  2. quickbi报错AE0510000002
  3. demo板 apt-get install stress
  4. bzoj4145 [AMPPZ2014]The Prices 状压 DP
  5. js image转canvas不显示
  6. SQL Server 2008 R2 数据库备份文件.bak如何挂载到【阿里云·独立虚拟主机数据库】上
  7. Vue $ref 的用法
  8. SCJP读书之知识点:
  9. Python3解leetcode Binary Tree PathsAdd Digits
  10. 使用vue-i18n实现项目的国际化 以及iview的国际化