Angular 2 router resolve with Observable

Don’t call subscribe() in your service and instead let the route subscribe. Change return this.searchService.searchFields().subscribe(fields => { to import ‘rxjs/add/operator/first’ // in imports return this.searchService.searchFields().map(fields => { … }).first(); This way an Observable is returned instead of a Subscription (which is returned by subscribe()). Currently the router waits for the observable to close. You can … Read more

Observables : Cancel previous http request on new subscription call

I would use a subject to keep everything reactive. In your template html listen to change events and emit a new value to the subject. <searchBar (change)=”search$.next($event.target.value)” /> then in your component: this.subscription = this.search$.pipe( debounceTime(800), distinctUntilChanged(), switchMap(searchText=>http.post(‘api_link’, {searchText}) }).subscribe(response=>{ this.response = response. }); The switchMap will cancel any HTTP request that hasn’t completed if … Read more

How to use angular 2 service with Ionic 2?

There is no use of Bootstrap() in Ionic2, only use of @App to declare your app. You still need to declare your service in your @Page component. Create your service import {Injectable} from “angular2/core”; import {Http} from “angular2/http”; @Injectable() export class DataService { constructor(http: Http) { this.http = http; this.data = null; } retrieveData() { … Read more

RxJs difference between complete and unsubscribe in Observable?

You complete an Observable, and unsubscribe a Subscription. These are two different methods on two different objects. You subscribe to an observable which returns a Subscription object. If you want to stop listening to emits from the Observable you call subscription.unsubscribe(). If you want an Observable to be done with his task, you call observable.complete(). … Read more

error: Could not find a declaration file for module ‘@ckeditor/ckeditor5-build-classic’ angular 9

Add typings.d.ts file in your project root or any folder add following code into the typing file declare module ‘@ckeditor/ckeditor5-build-classic’ { const ClassicEditorBuild: any; export = ClassicEditorBuild; } that’s it angular will automatically detect typings and compile it as dependency this will solve the issue its also sugggested in official CKEDITOR page: https://ckeditor.com/docs/ckeditor5/latest/builds/guides/integration/frameworks/angular.html Directory Structure

WARNING in ./node_modules/ng2-charts/fesm5/ng2-charts.js 230:54-72 “export ‘ɵɵdefineInjectable’ was not found in ‘@angular/core’

Update: May 2021 Recently I have used [email protected] in Angular v11 and it’s working fine. You may try with the latest version npm install ng2-charts@latest // it will automatically install latest version Older ng2-charts v2.2.4 has this bug as lots of users are reporting that so down-grading to ng2-charts v2.2.3 is fine until it is … Read more