Some instructions for using ANGULAR/CLI
NGCLI website Transfer Door new Project
ng New AppName
New Module
ng Generate ModuleName
Generate:
Like New class
Ng Generate class
Ng Generate component components
ng generate Directive Instructions
command can use the simplified mode class
ng G CL
Component and Class are all C-Component simplified to C,class to CL Component
Ng G C
And so on ... d:directive directives
Ng G D E:enum Enumeration
ng g E m:module Module
Ng G M P:pipe pipeline
ng G P s:service Service
Ng G S run project
Use NPM to download the dependent packages needed before running the project
Use the following command
The use of NPM in China requires the right Internet access, or there will be dependent download incomplete and so on.
The bad news is that domestic crackdown has increased some VPNs have been blocked, so it is recommended to use the NPM image of Taobao.
This is a full npmjs.org mirror, you can use this instead of the official version (read only), the synchronization frequency is currently 10 minutes to ensure that as far as possible with the official service synchronization.
Taobao NPM mirrored delivery door
In addition to the global install CNPM, you can also set the source of the change NPM
View the default source
npm config get registry
//temporary use of Taobao source installation Express
NPM--registry https://registry.npm.taobao.org Install [Express]
//The source of persistent use of Taobao
Then directly using the NPM Install command to install, the requested address is Taobao mirror. Just like to change Maven's central warehouse address to Ali's.
It is recommended to use NPM Source Manager NRM, which allows you to quickly switch NPM sources, and now supports the following sources:
Npm
cnpm
Taobao
NJ (Nodejitsu)
rednpm
After the download is complete, the Node_modules folder is generated under the root directory, which contains all the dependent packages in the Package.json file. This project is ready to run.
Run the project using the following command
ng start
Simplifying commands
ng S
The default port is 4200 when it is run
For example, to change the port to 4201, you can add a parameter –port
ng s--port 4201
Enter localhost:4201 in the browser
compiling
Ng Build–prod–aot
The default is to generate the packaged folder dist in the root directory.
Simply change the OutDir parameter in the Tsconfig.json file to place the packaged file under any path.
Direct access to index.html will cause the following error
This is because the path problem of base in index.html file, remove '/', can access index.html file normally
<base href= "/" >
If you need to deploy to Tomcat, simply copy the contents of the Dist file to the past.
A better approach here is to change the OutDir path directly.