angular6

Angular 6 - HttpClient Keeping subscribe in the service but passing the result to the component

依然范特西╮ 提交于 2019-12-08 18:51:22
问题 I have a preject which contains a service (which gets the data) and a component (displays it). I would like the keep the code to the minimum on the app.component.ts. In the service I have: getPosts() { return this.http.get('https://jsonplaceholder.typicode.com/posts', httpOptions).subscribe( result => { return result; this.theData = result; }, error => { return error; } ); } and in my app.component.ts: getPostsFromService() { this.myService.getPosts(); } But of course, I need to get the

rxjs: EmptyError: no elements in sequence

怎甘沉沦 提交于 2019-12-08 16:31:33
问题 I am getting an error 'EmptyError: no elements in sequence' error when I go to localhost:8080. I have seen the thread Angular 5 EmptyError: no elements in sequence while making child routes but none of the answers seem to apply. I have "rxjs": "^5.5.6" and in my routes, I tried adding pathMatch: 'full', but the error is still displayed. Extract of my app-routing-module.ts const routes: Routes = [ { pathMatch: 'full', /* added recently for test purposes*/ path: '', component: RootComponent,

Angular Electron with Nodejs using (MEAN Stack)

回眸只為那壹抹淺笑 提交于 2019-12-08 13:48:29
问题 I have create a MEAN Stack Application (Angular 6). Now I want to convert my application into Desktop Application with the same. we can achieve that in electron so that i read this Article. by using this Article I have created my application. but I am not get request from the application to server(node.js). here is my angular req: postlogindata(body: any): Observable<any> { return this._http.post(`http://192.168.1.174:8085/login`, body, { observe:'body', withCredentials :true, headers:new

How to transfer rows between two different Grids (Ag-grid Angular 6) using Drag and Drop?

泪湿孤枕 提交于 2019-12-08 12:56:27
问题 I want to transfer rows between two grids, having same column definition, One grid will hold the "free devices" and the other grid will hold the "devices to be added" , Is there a solution for this using drag and drop to transfer rows between two grids or any other way. 回答1: This feature is in ag-grid-pipeline and planned for Next Release as of now. AG-1708: Row dragging: Allow dragging between grids or between the grid and a external element 来源: https://stackoverflow.com/questions/55685188

Two way data binding of images using ngFor in angular 6

旧巷老猫 提交于 2019-12-08 11:58:14
问题 I am using angular 6 and infinite scroll. Requesting the data using http service, I am able to bind the data(images) to dom on init. But I am fetching the next number of records on scroll end using infinite scroll. On scroll of I am triggering the function and pushing to the same array, and it is reflecting in ts(checked using debugger). But not binding in Html. It may be possible duplicate, But no solutions helped me. and also please give the correct way of debounce method implementation in

Angular subscribe push object to array

吃可爱长大的小学妹 提交于 2019-12-08 11:03:22
问题 I am making angular application and where i am having an empty array like, users: any = []; Then i am making a service call in ngOnInit to store the data into users array like, ngOnInit() { //Getting the data from json this.httpClient.get('https://api.myjson.com/bins/n5p2m').subscribe((response: any) => { console.log("response", response.data); response.data.forEach(element => { //Pusing the data to users array this.users.push(element); }); }) //Trying to get the complete array after push of

Angular 6 and PHP: HttpClient is not sending arrays to server even when using append into httpParams

試著忘記壹切 提交于 2019-12-08 10:55:54
问题 I need to send an array of data using HttpClient of Angular 6 to PHP server. I have some drop down list where I chose from and push into an array: arrayOfLegalProtection=[]; addSit(){ let l_id = ''; let p_id = ''; let s_id = ''; let add_date = ''; l_id = this.formGroup.controls['l_id'].value; p_id = this.formGroup.controls['p_id'].value; s_id = this.formGroup.controls['s_id'].value; add_date = this.formGroup.controls['add_date'].value; this.showSubHeader++; this.arrayOfLegalProtection.push(

Angular : Call Function from different component with Service Sharing

浪子不回头ぞ 提交于 2019-12-08 10:28:39
问题 I want to achieve this - // component1 load(){ // code... } // component2 component1.load(); So, basically I just want to call function of different component from a component. I have read through the internet that there are 3 ways to share data between components, In my app, I am using Service Sharing to share data between my components. But how I can simply call a function from different component with service sharing approach ? 回答1: You can use the following service based on observables.

How to get the new coordinates from Angular Google Maps? (Angular 6)

本秂侑毒 提交于 2019-12-08 09:13:21
问题 Background: Hello everyone, for the last days I am struggling with angular google maps (AGM) API. I am building something pretty simple, I have list of coordinates ( longitude and latitude ) which I am passing to AGM directive, everything work fine and I am able to see the points on the map, check out the image (line image and polygon image): Line Image: Polygon Image: This is my angular code to display the line and display the polygons. <agm-map #agmMap class="d-agm-map-container" [zoom]=

Format input as number with locale in Angular 6

夙愿已清 提交于 2019-12-08 08:14:40
问题 I am trying to format a number in a text input in the locale of the user. I tried to use DecimalPipe and a custom self-made pipe and both work at first. The problem is, as soon as the number is formated into a string, the pipe doesn't work anymore since it is supposed to be applied on a number. So for example when I type 1234.23 , it displays 1 234,23 but the DecimalPipe doesn't work on 1 234,23 and I get the NaN error. I didn't find anything that allows me to turn back the formatted text