We are no longer accepting contributions to Documentation. Please see our post on meta.

Angular 2

Angular-cli All Versions

2.0.0-rc.0
2.0.0-rc.1
2.0.0-rc.2
2.0.0-rc.3
2.0.0-rc.4
2.0.0-rc.5
2.0.0-rc.6
2.0.0-rc.7
2.0.0
2.0.1
2.0.2
2.1.0
2.2.0
2.3.0
4.0.0
4.1.0
4.2.0
4.3.0
4.3.1
4.3.2
4.3.3

Here you will find how to start with angular-cli , generating new component/service/pipe/module with angular-cli , add 3 party like bootstrap , build angular project.

This draft deletes the entire topic.

Examples

  • 0

    In angular-cli.json you can change the app configuration.

    If you want to add ng2-bootstrap for example:

    1. npm install ng2-bootstrap --save or yarn add ng2-bootstrap

    2. In angular-cli.json just add the path of the bootstrap at node-modules.

      "scripts": [
          "../node_modules/jquery/dist/jquery.js",
          "../node_modules/bootstrap/dist/js/bootstrap.js"
       ]
      
  • 0

    In angular-cli.json at outDir key you can define your build directory;

    these are equivalent

    ng build --target=production --environment=prod
    ng build --prod --env=prod
    ng build --prod
    

    and so are these

    ng build --target=development --environment=dev
    ng build --dev --e=dev
    ng build --dev
    ng build
    

    When building you can modify base tag () in your index.html with --base-href your-url option.

    Sets base tag href to /myUrl/ in your index.html

    ng build --base-href /myUrl/
    ng build --bh /myUrl/
    
  • 0

    Requirements:


    Run the following commands with cmd from new directory folder:

    1. npm install -g @angular/cli or yarn global add @angular/cli
    2. ng new PROJECT_NAME
    3. cd PROJECT_NAME
    4. ng serve

    Open your browser at localhost:4200

  • 0

    just use your cmd: You can use the ng generate (or just ng g) command to generate Angular components:

    • Component: ng g component my-new-component
    • Directive: ng g directive my-new-directive
    • Pipe: ng g pipe my-new-pipe
    • Service: ng g service my-new-service
    • Class: ng g class my-new-classt
    • Interface: ng g interface my-new-interface
    • Enum: ng g enum my-new-enum
    • Module: ng g module my-module
  • 0

    The default style files generated and compiled by @angular/cli are css.

    If you want to use scss instead, generate your project with:

    ng new project_name --style=scss
    

    If you want to use sass, generate your project with:

    ng new project_name --style=sass
    
  • 0

    Yarn is an alternative for npm, the default package manager on @angular/cli. If you want to use yarn as package manager for @angular/cli follow this steps:

    Requirements

    To set yarn as @angular/cli package manager:

    ng set --global packageManager=yarn

    To set back npm as @angular/cli package manager:

    ng set --global packageManager=npm

Please consider making a request to improve this example.

Syntax

Syntax

Parameters

Parameters

Remarks

Remarks

Still have a question about Angular-cli? Ask Question

Topic Outline


    We are no longer accepting contributions to Documentation. Drafts cannot be modified.