How to add/set environment Angular 6 angular.json file

Open angular.json file. we can see the configurations by default it will be shown for production add code snippet for your respective environments. add environment.dev.ts file in environment for dev, add environment.qa.ts for qa. Name as you prefered. use ng serve –configuration=environment_name environment_name – (dev,qa,prod) same process can be followed for ng build “configurations”: { … Read more

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

After trying a few different methods, I came across this one that resolves my issue and only makes one HTTP request no matter how many subscribers there are: class SharedService { someDataObservable: Observable<any>; constructor(private http: HttpClient) {} getSomeData(): Observable<any> { if (this.someDataObservable) { return this.someDataObservable; } else { this.someDataObservable = this.http.get<any>(‘some/endpoint’).pipe(share()); return this.someDataObservable; } } … Read more

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

This is how to filter router events with Angular 6+ and latest RxJS: import { Component, OnInit } from ‘@angular/core’; import { Router, ActivatedRoute, NavigationEnd } from ‘@angular/router’; import { filter } from ‘rxjs/operators’; export class MyComponent implements OnInit { constructor(private router: Router, private activatedRoute: ActivatedRoute) {} ngOnInit() { this.router.events.pipe( filter(event => event instanceof NavigationEnd) … Read more

Cannot find module ‘webpack’ – Angular

I had the same issue and this worked for me: Delete these files/ folders (from your Angular root folder): package-lock.json (Not the package.json) /node_modules folder /dist folder Execute command (regenerate the package-lock.json and the /node_modules): $npm install Everything should work now, it was the package-lock.json that caused npm to download old versions of dependencies.

angular 6 dependency injection

Basically you can use either, But as per new CLI provideIn will be automatically added while creating service #providedIn There is now a new, recommended, way to register a provider, directly inside the @Injectable() decorator, using the new providedIn attribute. It accepts ‘root’ as a value or any module of your application. When you use … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)