Questions tagged [angular-cli]

The Angular CLI is a command line interface for building, managing and deploying Angular (version 2+) applications.

The Angular CLI is a command line interface for building, managing and deploying Angular (version 2+) applications. It can be used to generate part of the application, serving in a local server, analysing code quality, etc. It is based on ember-cli project.

Installation

npm install -g @angular/cli

Usage

ng help

Generating and serving an Angular project via a development server

ng new PROJECT-NAME
cd PROJECT-NAME
ng serve

For more information, please visit the following links.

7329 questions
67
votes
5 answers

angular 6 dependency injection

In the latest release of Angular 6, a service is registered in a module using the providedIn property in the service metadata: @Injectable({ providedIn: 'root', }) export class HeroService {} However the documentation still also refers to…
Hamed Baatour
  • 6,664
  • 3
  • 35
  • 47
66
votes
3 answers

Difference between tsconfig.json and tsconfig.app.json files in Angular

I'm a newbie in Angular. I used angular-cli to learn about angular and I found the files tsconfig.json and tsconfig.app.json. Both of these are typescript related and I found this link useful. But why two such files has been used? Why can't the…
kmg
  • 1,195
  • 3
  • 11
  • 14
66
votes
3 answers

Install specific version of ng cli

I'm using angular 2.4.9 for my application development so I need to use specific version of ng cli instead of the latest one. I know the below command will install latest version of ng cli npm install -g @angular/cli But how can I install specific…
Gangadhar Jannu
  • 4,136
  • 6
  • 29
  • 49
66
votes
5 answers

AngularCli: disable minification

Is there a way to disable the minification in AngularCli? After I launch the command ng build --prod I need to have all files.js, in dist folder, separate and legible.
Danieleee
  • 721
  • 1
  • 6
  • 6
66
votes
19 answers

Angular 2 Routing Does Not Work When Deployed to Http Server

I am going to develop a simple Angular 2 application. I have created a project with routing, using Angular CLI and added several components to the app using 'ng generate component ' command. Then I specified routing in the app-routing.module.ts as…
kinath_ru
  • 4,488
  • 3
  • 21
  • 26
65
votes
3 answers

Include assets when building angular library

I am building a library which contains a custom icon font. However, when I build my library using ng build --prod, the assets folder is not included in the build, which means icons do not show up when using the production build. I've…
65
votes
2 answers

Angular CLI HMR with Lazy-Loaded routes hot-reloads the whole thing

(Confirmed an issue even with Angular 7). Let's get this fixed! I'm using HMR as set up here: https://github.com/angular/angular-cli/wiki/stories-configure-hmr from a fresh ng new build. If I change any component and make it lazy loaded, angular…
65
votes
4 answers

how to format date in Component of angular 5

I am new to angular and looking to format date in component ngOnInit method. I have seen some example where pipe operator are used to format the data but i dont know how to format date in component file. below is code export class…
Feroz Siddiqui
  • 3,840
  • 6
  • 34
  • 69
64
votes
9 answers

"You seem to not be depending on "@angular/core"."

When I try to build my project running the following command: ng build --environment=prod --aot=false --output-path="..." --base-href="..." You seem to not be depending on @angular/core. This is an error, however, I don't understand why because…
Floriane
  • 671
  • 1
  • 5
  • 9
64
votes
5 answers

Debug Tests in NG Test

I am using Angular CLI and VSCode but none of my breakpoints in my spec files seem to be getting hit when I run ng test? Do I need to do some config?
72GM
  • 2,926
  • 3
  • 27
  • 33
64
votes
5 answers

Passing environment variables to angular library

I've created company internal library using angualr2-library yeoman generator. Some of the angular services are using environment variables in our current applications (api endpoints are changed on each env). I was wondering what is the best way to…
Dima Grossman
  • 2,800
  • 2
  • 21
  • 26
63
votes
6 answers

Load new modules dynamically in run-time with Angular CLI & Angular 5

Currently I'm working on a project which is being hosted on a clients server. For new 'modules' there is no intention to recompile the entire application. That said, the client wants to update the router/lazy loaded modules in runtime. I've tried…
Lars Meijdam
  • 1,177
  • 1
  • 10
  • 18
62
votes
6 answers

Angular 4 Bootstrap dropdown require Popper.js

I have a fresh created Angular 4 CLI app. After running this: npm install bootstrap@4.0.0-beta jquery popper.js --save and editing .angular-cli.json like this: "styles": [ "styles.css", …
mikebrsv
  • 1,890
  • 2
  • 24
  • 31
62
votes
2 answers

How to compress and optimise an Angular2 application

I want to make my angular-cli application faster! Right, so I have spent a number of days updating my NG2 application to work with angular-cli. At first it was quite a frustrating experience, however, I am really seeing the light and enjoying the…
HappyCoder
  • 5,985
  • 6
  • 42
  • 73
62
votes
14 answers

Angular2 Cannot find namespace 'google'

I am working with angular2-google-maps and latest version of Angular2. I am trying to convert some of the local map component functions into services in their own file maps.service.ts. For example: map.component.ts getGeoLocation(lat: number, lng:…
Milo
  • 3,365
  • 9
  • 30
  • 44