Questions tagged [angular6]

Questions about Angular version 6, the web framework from Google. Use this tag for Angular questions which are specific to only version 6. Use tag Angular for any Angular questions which are not specific to an individual version.

Questions about Angular version 6, the web framework from Google.

You can read more about Angular version 6 here

You can find Angular version 6 official documents here

7869 questions
78
votes
5 answers

How to run the Dist Folder on Local Machine in Angular 6+?

I am building the application in Angular6+, now I ran the command ng build --prod which gave me a dist folder. How do I check or serve that folder on Localhost?
Jignesh Mistry
  • 2,221
  • 6
  • 25
  • 50
77
votes
6 answers

how to pass data from angular material dialog to parent component?

I'm using angular 6 and I have a button which opens a dialog. in my dialog, I have a form that gets user's data and then I have two buttons to submit and cancel. I tried to show my form's data in the console but it returns undefined! whats the…
fariba.j
  • 1,737
  • 7
  • 23
  • 42
77
votes
3 answers

Difference between ng add vs npm install in angular 6

As Angular6 has been released, They have added a new command ng add . Can anyone tell me what will be the difference between existing command npm install and ng add
Nimish goel
  • 2,561
  • 6
  • 27
  • 42
75
votes
9 answers

Upgrading to angular-6.x gives "Uncaught ReferenceError: global is not defined"

I upgraded my project from angular-5.x to angular-6.x and it started giving the following error and even creation of dummy global variable does not work as given here Angular 6 Auth0 - global not defined The error is as follows: Uncaught…
Atikur Rahman
  • 1,043
  • 1
  • 7
  • 14
72
votes
16 answers

Angular 6 Unit Tests: An error was thrown in afterAll\nReferenceError: Can't find variable: $ thrown

When running my unit tests, from time to time, even if they pass, at the end of all the tests running, I will get the following error. On my Jenkins CI build running PhantomJS: .PhantomJS 2.1.1 (Linux 0.0.0) ERROR { "message": "An error was…
Oisin
  • 2,082
  • 2
  • 12
  • 8
70
votes
11 answers

The NPM script 'start' exited without indicating that the Angular CLI was listening for requests

I'm attempting to start an .NET Core 2/Angular 6 SPA. I created an Angular 5 Application using "dotnet new angular" then proceeded to upgrade using this guide from angular.io. Once I finished the upgrade I tried to run the application using "dotnet…
mack
  • 2,715
  • 8
  • 40
  • 68
67
votes
9 answers

How to use environment variable in index.html for Angular 6

I am using angular6, in my project I am using Facebook Account Toolkit for mobile verification purpose. I need to initialise Account toolkit in index.html file using following code. AccountKit.init({ appId:"XX", state:"xx", …
Shavareppa
  • 990
  • 1
  • 6
  • 14
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
65
votes
8 answers

How to get the current year using typescript in angular6

How to get the current year using typescript in angular6 currentYear:Date; this.currentYear=new Date("YYYY"); alert(this.currentYear); It shows Invalid Date
Revathi Vijay
  • 1,238
  • 1
  • 13
  • 25
64
votes
11 answers

Angular 6 many Can't resolve errors (crypto, fs, http, https, net, path, stream, tls, zlib)

I'm building an Angular 6 app, but every time I want to serve to localhost, I get these errors: ERROR in ./node_modules/aws-sign2/index.js Module not found: Error: Can't resolve 'crypto' in…
Zizazorro
  • 1,321
  • 2
  • 11
  • 19
62
votes
8 answers

When upgrading Angular 5 to 6, I get incompatible peer dependency (using ng update @angular/core)

I am trying to update my Angular app from v5 to v6 following this guide. I have ran all these commands successfully: npm install -g @angular/cli npm install @angular/cli ng update @angular/cli The problem is that I get an error when running this…
Ahmed Elkoussy
  • 8,162
  • 10
  • 60
  • 85
60
votes
6 answers

Cannot find module 'webpack' - Angular

I just migrated my project from angular v5.x to v6.x and now when I try to start it with ng serve I'm getting: Cannot find module 'webpack' Error: Cannot find module 'webpack' at Function.Module.... any help ? I cleared node modules and: npm…
kosnkov
  • 5,609
  • 13
  • 66
  • 107
55
votes
7 answers

Angular/RxJS 6: How to prevent duplicate HTTP requests?

Currently have a scenario where a method within a shared service is used by multiple components. This method makes an HTTP call to an endpoint that will always have the same response and returns an Observable. Is it possible to share the first…
patryk0605
  • 1,081
  • 1
  • 9
  • 10
54
votes
3 answers

Angular 6 router.events.filter 'filter' does not exist on type 'Observable'

I have finished to update my App to Angular 6 (it was in 5.2 version). I got an error syntax in : import { Router, ActivatedRoute, NavigationEnd } from '@angular/router'; import { filter } from 'rxjs/operators'; ... constructor(private router:…
Anouar Mokhtari
  • 2,084
  • 4
  • 23
  • 23
53
votes
1 answer

Angular service decorator providedIn root effect on lazy loading

I am wondering how the new angular service decorator @Injectable({ providedIn: 'root' }) works in conjuction with lazy loading. Meaning if I have a lazy loaded module, with a service that is providedIn root, will this include the specific…
Karl Johan Vallner
  • 3,980
  • 4
  • 35
  • 46