Error: : fromEvent is not declared writable or has no setter

You need to spy on a property of rxjs. Using spyOnProperty will solve the error. Try this import * as rxjs from ‘rxjs’ import { of, fromEvent } from ‘rxjs’; spyOnProperty(rxjs, ‘fromEvent’).and.returnValue(of({})) you can also add to getter/setters using this like spyOnProperty(rxjs, ‘fromEvent’, ‘get’).and.returnValue(false) Hope this helps

Type ‘Promise’ is not assignable to type ‘string[]’

Assume your response from http.get is an array, here you are returning Promise from function memberService.getmemberheader, you should retrieve result of promise at its then callback instead (not assigning promise itself to array doughnutChartLabels). public doughnutChartLabels: string[]; this.memberService.getmemberheader().then(res => { this.doughnutChartLabels = res; })

Angular2: Export of RouterModule, Why it is required?

You don’t need to export it. It’s just for convenience. If you add AppRoutingModule to AppModule you also implicitly import RouterModule this way. Otherwise you would need to import it explicitely @NgModule({ imports: [AppRoutingModule, RouterModule], }) export class AppModule {} for example to be able to use <router-outlet> or RouterLink in components declared in AppModule

Angular 6, should I put secret environment variables in environment.ts file?

TL; DR You should not treat environment.ts as something similar to process.env. The name is similar but the behaviour is absolutely not. All the settings from environment.ts will directly go to your code. That’s why it is not secure to put secrets to environments.ts in any way. The browser alternatives to environment variables (process.env) are … Read more

How to wait for a http request to finish in Angular?

You can use promises with async/await async getUser() { if (this.storage.token == null || this.storage.token == ”) { return; } const t = await this.net.get<LoginModel>(`Authentication/GetUser`).toPromise(); this.storage.token = t.token; this.storage.user = t.user; console.log(this.storage.user); } See more: Promises async await ES8 async/await async/await tutorial async/await explained

Do I need to complete a Subject for it to be garbage collected?

If you look at the source for Subject.complete, you’ll find the answer: complete() { if (this.closed) { throw new ObjectUnsubscribedError(); } this.isStopped = true; const { observers } = this; const len = observers.length; const copy = observers.slice(); for (let i = 0; i < len; i++) { copy[i].complete(); } this.observers.length = 0; } Calling … Read more