angular ng经常使用命令

1.启动应用服务器浏览器

//命令会构建本应用、启动开发服务器、监听源文件,而且当那些文件发生变化时从新构建本应用。服务器

ng serve 

  //--open标志会打开浏览器,并访问 http://localhost:4200/app

 ng serve --open

 //--port标志浏览器端口,并访问 http://localhost:4201/单元测试

ng serve --port 4201 --open

2.建立列表组件测试

ng generate component heroes //使用 Angular CLI 建立一个名为 heroes 的新组件。

可缩写,同样的效果ui

ng g component heroes

也可缩写,不会生成单元测试文件 heroes.component.spec.tscode

ng g c --spec= false heroes

3.使用 Angular CLI 建立一个名叫hero服务component

ng generate service hero

能够经过--module=app 选项让 CLI 自动把它提供给 AppModule。开发

ng generate service hero --module=app

也可写module

ng g service hero -m app.module

4.打包

ng build -prod

也能够简写

ng b -prod
相关文章
相关标签/搜索