Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Commons commands in Angular CLI

Commons commands in Angular CLI

A few important commands that you should know to work with Angular 2.

Yair Carreno

April 22, 2017
Tweet

More Decks by Yair Carreno

Other Decks in Programming

Transcript

  1. Angular CLI Commands Generating new projects Generating components Generating services

    ng new my-app ng new my-app --dry-run ng g c my-component ng g s my-service Generate a new app in /my-app Don’t write the files, but report them. Generate a new component. Generate a new service. ng new my-app --ng4 --routing Generate app with routing class included. ng new my-app --style sass ng new my-app --prefix mp Style should use SASS Set the default selector prefix(i.e. mp). Generating directives ng g d my-directive Generate a new directive. Generating interfaces ng g i my-interface Generate a new interface. Generating pipes ng g p my-pipe Generate a new pipe. Build commands ng build Output dev build files. Generating modules ng g module my-module Generate my-module.module.ts. Serving commands ng serve Serve a dev build in memory. Generating classes ng g cl my-class-model Generate a new model class. Generating enums ng g e my-enum Generate a new enum. Generating guards ng g guard auth CanActive guard auth.guard.ts. Common commands --flat Don’t create a /my-component folder. ng serve -o Serve and lanch the browser. ng g d my-directive --flat false Generate a directive in your own folder. ng build --prod Output prod build files. ng g s my-service -m app.module Include the provider service into app.module class. ng g module my-module --routing Generate my-module.module.ts and my-module-routing.module.ts. --inline-template Put the template in the .ts file. --inline-style Put the style in the .ts file. --spec false Don’t create a spec file. Linting ng lint Lint the typescript code. By @yaircarreno with special thanks to @John_Papa and @DeborahKurata.