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
883
votes
47 answers

Angular 6 - Could not find module "@angular-devkit/build-angular"

After updating to Angular 6.0.1, I get the following error on ng serve: Could not find module "@angular-devkit/build-angular" from "/home/Projects/myProjectName". Error: Could not find module "@angular-devkit/build-angular" from…
ForestG
  • 17,538
  • 14
  • 52
  • 86
270
votes
8 answers

What is the purpose of providedIn with the Injectable decorator when generating Services in Angular 6?

When generating services in the Angular CLI, it is adding extra metadata with a 'provided in' property with a default of 'root' for the Injectable decorator. @Injectable({ providedIn: 'root', }) What exactly does providedIn do? I am assuming…
Stefan Zvonar
  • 3,959
  • 3
  • 24
  • 30
246
votes
8 answers

How to set environment via `ng serve` in Angular 6

I am trying to update my Angular 5.2 app to Angular 6. I successfully followed instructions in the Angular update guide (including the update of angular-cli to v6), and now I am trying to serve the app via ng serve --env=local But this gives me…
Martin Adámek
  • 16,771
  • 5
  • 45
  • 64
210
votes
7 answers

Angular 6 Material mat-select change method removed

In Angular Material Design 6, the (change) method was removed. How should I replace the change method to execute code in the component when the user changes selection?
Fernando Lacoumette
  • 2,233
  • 2
  • 11
  • 9
205
votes
17 answers

Angular-cli from css to scss

I've read the documentation, which says that if I want to use scss I have to run the following command: ng set defaults.styleExt scss But when I do that and make that file, I still receive this error in my console: styles.bundle.js:33Uncaught…
Jamie
  • 10,302
  • 32
  • 103
  • 186
196
votes
18 answers

Errors: Data path ".builders['app-shell']" should have required property 'class'

I am getting this error while running my application. Here are the details of my application. Angular CLI: 7.3.3 Node: 10.15.1 Angular: 7.2.7 @angular-devkit/architect -0.13.3 @angular-devkit/build-angular- 0.800.1…
Ekta Gandhi
  • 1,979
  • 2
  • 7
  • 5
193
votes
6 answers

Multiple ng-content

I am trying to build a custom component using multiple ng-content in Angular 6, but this is not working and I have no idea why. This is my component code:
Lucas Santos
  • 2,991
  • 3
  • 19
  • 29
184
votes
16 answers

Angular - "has no exported member 'Observable'"

Typescript code: import { Injectable } from '@angular/core'; import { Observable } from 'rxjs/Observable'; import { of } from 'rxjs/observable/of'; import { Hero } from './hero'; import { HEROES } from './mock-heroes'; @Injectable({ providedIn:…
Thomas Lee
  • 2,757
  • 2
  • 11
  • 13
150
votes
6 answers

Angular 6 - Why use @ngrx/store rather than service injection

I am recently learning Angular 6 with @ngrx/store while one of the tutorial is to use @ngrx/store for state management, however I don't understand the benefit of using @ngrx/store behind the scene. For example, for a simple login and signup action,…
Drex
  • 3,346
  • 9
  • 33
  • 58
98
votes
4 answers

How to pass multiple parameter to @Directives (@Components) in Angular with TypeScript?

Since I've created @Directive as SelectableDirective, I'm little bit confused, about how to pass more than one value to the custom directive. I have searched a lot but didn't get proper solution in Angular with Typescript. Here is what my sample…
Sagar Ganesh
  • 2,454
  • 3
  • 20
  • 32
97
votes
5 answers

Angular6 Material6 Error: "There can only be one default row without a when predicate function."

I'm trying to implement the Table with expandable rows from https://material.angular.io/components/table/examples but I get this error: There can only be one default row without a when predicate function. This error comes from the fact that I have…
GoTo
  • 5,966
  • 2
  • 28
  • 31
95
votes
23 answers

Error: Schema validation failed with the following errors: Data path "" should NOT have additional properties(project)

After migrating application from angular 5 to 6, on running ng serve the following errors pop up. Schema validation failed with the following errors: Data path "" should NOT have additional properties(project). Error: Schema validation failed…
V5NEXT
  • 1,907
  • 4
  • 19
  • 38
89
votes
7 answers

Angular 6 View is not updated after changing a variable within subscribe

Why is the view not being updated when a variable changes within a subscribe? I have this code: example.component.ts testVariable: string; ngOnInit() { this.testVariable = 'foo'; this.someService.someObservable.subscribe( () =>…
80
votes
8 answers

Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

Has anyone faced below warning in "ng serve"? WARNING in ./node_modules/@angular/compiler/src/util.js 10:24-31 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted ℹ 「wdm」: Compiled with…
Aman
  • 1,292
  • 1
  • 14
  • 20
78
votes
7 answers

Angular 6 Downloading file from rest api

I have my REST API where I put my pdf file, now I want my angular app to download it on click via my web browser but I got HttpErrorResponse "Unexpected token % in JSON at position 0" "SyntaxError: Unexpected token % in JSON at position 0↵ at…
gmexo
  • 1,892
  • 2
  • 14
  • 19
1
2 3
99 100