angular6

Angular 6 : where getting error module “rxjs/add/operator/map” and another error 'map' does not exist on type 'Observable<Response>'

拈花ヽ惹草 提交于 2019-12-30 17:19:49
问题 I am using Angular 6 where I am getting two errors - ERROR in ./src/app/app/img/img.service.ts Module not found: Error: Can't resolve 'rxjs/add/operator/map' in '/Users/user/Projects/A4/imageSearch/src/app/app/img' ERROR in src/app/app/img/img.service.ts(21,9): error TS2339: Property 'map' does not exist on type 'Observable'. 回答1: I faced similar problem with rxjs map operator. Currently I'm using Angular 6. To know which version you are using: ng --version or ng -v If you are also using

Appending HTML snippet to the view in Angular 6

杀马特。学长 韩版系。学妹 提交于 2019-12-30 11:44:18
问题 I am getting a piece of html code from a http request to an external system , and I should show this on my view in my angular app to be percise this is the html snippet that I have to show (it will be a bit different by every request and response ) <div id='paysonContainer' url='https://test-www.payson.se/embedded/checkout?id=af1ebee5-40bd-410a-90d1-a94401553414'> </div> <script type='text/javascript' src='https://test-www.payson.se/embedded/Content/payson.js?v2'> </script> I used different

Angular6 Service Worker and background sync

陌路散爱 提交于 2019-12-30 06:18:07
问题 it seems that angular6 does not support background syncing with service worker. What are the steps required to do this without any library in an angular service? https://developers.google.com/web/updates/2015/12/background-sync How and where can I access WorkerGlobalScope in an angular6 application directly so that background sync can be done.: self.addEventListener('sync', function(event) { if (event.tag == 'myFirstSync') { event.waitUntil(doSomeStuff()); } }); The problem is that the

How to use formGroupName inside child components

余生长醉 提交于 2019-12-30 04:46:09
问题 How do i use formGroupName inside child components? for example: i have ParentFormComponent parentForm: FormGroup; constructor(private fb: FormBuilder, private http: Http) { } ngOnInit() { this.parentForm = this.fb.group({ _general: this.fb.group ({ ProjectName:'' }) }) } In the html: <form [formGroup]="parentForm" (ngSubmit)="submitForm()"> <div formGroupName="_general"> <mat-form-field> <input matInput placeholder="Project name" formControlName="ProjectName"> </mat-form-field> </div> </form

Angular : how to call finally() with RXJS 6

落花浮王杯 提交于 2019-12-30 01:47:16
问题 I was using RXJS 5, now as I upgraded it to 6, I am facing some problems. Previously I was able to use catch and finally but as per update catch is replaced with catchError (with in the pipe) now how to use finally? Also I have some questions : Do I need to change throw->throwError (in below code Observable.throw(err);) import { Observable, Subject, EMPTY, throwError } from "rxjs"; import { catchError } from 'rxjs/operators'; return next.handle(clonedreq).pipe( catchError((err:

angular 6 dependency injection

匆匆过客 提交于 2019-12-29 10:53:47
问题 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 registering the service in the module providers array in the module metadata just like we did in Angular 5: @NgModule({ providers: [HeroService], }) export class AppModule {} So, Which method should be used to make the injector aware of the service that it

How to change URLs automatically in services, after changing URL it should affect to all components without saving/ building/running in angular6

天大地大妈咪最大 提交于 2019-12-29 02:00:07
问题 We are hosting a new application with angular 6 and we have many servers with diff URLs, i want to change them automatically(like .property file in java). after searching in google i got some answers like changing paths in environment.ts file, so it will affect to all components. but its not exactly my requirements, means if i change URL in environment.ts file, we should save the file and we need to compile it once again. So exactly this is the problem i am facing, i don't want to save /

Why are runtime.js, styles.js created on ng serve command

坚强是说给别人听的谎言 提交于 2019-12-26 03:53:45
问题 Greetings fellow programmers I am new to angular and I wanted to know why are these two files created when I run ng serve command. these are the files I know why other 3 files are created (main.js, polyfills.js, vendor.js) but I don't know about the 2 files I mentioned (runtime.js, styles.js) I tried googling it too but no information came on these two files. Any help is appreciated. 回答1: I am not good in explanation but let me give my understanding on these things. Its basically webpack (AOT

Interactive features in vector layers in openlayers 5

拟墨画扇 提交于 2019-12-25 18:12:22
问题 I am using openlayers 5.1.3 and I confused as to how to create the functionality of clicking on a feature of a vector layer, get exactly the one I clicked and then get its properties. I am following this example that is the only relevant I found. I have an empty vector source that gets GeoJSON data after search initialize the map and the vector this.vectorsource = new VectorSource({}); this.vectorlayer = new VectorLayer({ source: this.vectorsource }); var selectClick = new Select({ condition:

Shared Variable Used Globally in Angular 6 Components

荒凉一梦 提交于 2019-12-25 03:38:27
问题 I am working on Angular6 todo list task app. I have tasks categories when click on category I get this category's tasks it working with me well but I need to set categories in nav-component like image below. so I need store selected category id in value to use it in todo-component any help ..? 回答1: I found a way to make a shareable Object : create new service called GlobaleVariable.ts and write this on it : @Injectable() export class GlobalVariblesClass { sharedCategory$ = new ReplaySubject