Sunday, May 21, 2017

Some basic Angular command line interface (CLI) stuff.

I'm starting to chew my way through a training on Angular 4. Some of it is stuff I already know, but it has delved into some of the command line stuff which is new for me. This globally installs the command line stuff.

npm install -g @angular/cli

 
 

You have to use the sudo ("substitute user do" or "super user do") keyword on a Mac or in Linux. There will be other places below where sudo applies, but I won't delve into all that.

sudo npm install -g @angular/cli

 
 

This creates a new project called whatever in a folder called whatever.

ng new whatever

 
 

Build the source code for your app and run a little web server for it. The HTTP protocol must be in place to use Angular 4 so you cannot just open index.html (for an Angular 4 app) as a file and expect it to work well.

ng serve

 
 

Addendum 5/23/2017: ng generate component whatever or even ng g c whatever will make a new folder with a component called whatever in it.

 
 

Addendum 6/4/2017: ng g c whatever --spec false will make a component without making a spec file for testing and ng g c whatevers/whatever is an example of giving which folder to make a component.

 
 

Addendum 6/17/2017: ng g d whatever is going to create a directive in a file dubbed whatever.directive.ts

 
 

Addendum 8/12/2017: ng generate pipe whatever is going to create a pipe called whatever and so will ng g p whatever

 
 

Addendum 9/4/2017: Some distinctions between Just-in-Time compilation and the alternative Ahead-of-Time compilation are:

  • ng build
     ...just builds
     
  • ng build --prod
     ...builds and minifies
     
  • ng build --prod --aot
     ...builds, minifies, and uses Ahead-of-Time compilation

No comments:

Post a Comment