Questions tagged [angular2-services]

Use this tag for questions related to Angular 2 Services, which are JavaScript functions responsible for performing a single task.

Useful Links:

  1. Services - tutorial
2204 questions
0
votes
1 answer

POST after a GET and consume it on Angular2

I want to create a service which does a GET and a POST and use it on a component. What's the best way to do it? auth.service.ts getToken() { return this.http.get(this.getServerUrl() + '/token'); } login(username: string, password: string) { …
sok
  • 612
  • 2
  • 10
  • 24
0
votes
1 answer

How to update the updated service value in all the components using angular2

we have two components shared same service, we change the service value in one component that value i need to update other component also. app.component.ts import { Component } from '@angular/core'; import {ConfigurationService} from…
CodeMan
  • 1,941
  • 6
  • 26
  • 44
0
votes
2 answers

UI is not showing server data in angular 2

I am a novice in angular 2 and started learning the concepts. I have a component which is not showing data when bound with my controller. The Ui gets loaded with hard coded data though. Here is my Component personal-details.component.ts import {…
sandeep
  • 1
  • 2
0
votes
1 answer

Calling service from a function angular2

I'm trying to call a service from a function but i'm getting this error in the console: Cannot read property 'TestMethod' of undefined This is my code: app.component.ts: constructor(public _service: BackendFileCodeService){ } public editor; …
Fares Ayyad
  • 383
  • 1
  • 3
  • 18
0
votes
1 answer

typescript how to filter json by date range

I have a json data as below. I am using angular2 typescript to filter this json based on the date range. I am using Moment to format the date string. I need to filter the searchvalue against all the properties of the class. I managed with other…
Mukil Deepthi
  • 6,072
  • 13
  • 71
  • 156
0
votes
1 answer

gGet the position from the LocationService angular2

I have a location service export class MapService { location: Position; allOptions; ngOnInit() { if(navigator.geolocation){ navigator.geolocation.getCurrentPosition( position => { …
Djama
  • 661
  • 5
  • 11
  • 28
0
votes
1 answer

Listen to variable update in service Angular2/4

I have some object in global service. One of component uses socket and updates this object, but other component doesn't get any changes. PlanService @Injectable() export class PlanService { private subject = new Subject(); private…
Olga Matosova
  • 136
  • 1
  • 1
  • 10
0
votes
0 answers

Angular 2 Service has 2 instances despite not in two providers arrays

I know the dangers of having a service in more than one providers: [] arrays in components, and that it is best to have services in the app module providers array. In our case there is one service that is only in the app module providers array, but…
Greg Lafrance
  • 768
  • 1
  • 7
  • 18
0
votes
1 answer

Not able to get .then method from a subscribed service

I'm trying to get a success-error response after a patch request made inside a service. Although I can detech the success or error response in the service itself but I'm not able to "subscribe" or get a promise reply back to the function in the…
Manzur Khan
  • 2,366
  • 4
  • 23
  • 44
0
votes
1 answer

synchronous method angular 2

I have cell in grid that contains number of users per each company, this number comes from typescript method getNumberOfUsers() ,this method call Back-End web service return number of users . Issue: all cells displayed 0, Although…
0
votes
2 answers

Angular2 multiple REST endpoint calls

I'm trying to use more than one REST endpoint call in my angular 2 component. The problem is, that I'm not getting any data from no one of them. What I do is this: getData() { myService.getDataA().subscribe(data => { this.dataA = data }) …
0
votes
1 answer

Angular 4: Inject service having @angular/http as dependency in non-component class

Hi I'm newbie for Angular 4. I'm having one service named 'httpService' which is having @angular/http as one of dependency, there are others as well, which does error handling. Now i'm having normal class (other than component) say 'Child.ts' which…
Satish Lakhani
  • 445
  • 3
  • 10
0
votes
1 answer

How to start an app installed from a private npm registry inside another angular2 app

I have created individual apps and published them into a private npm registry. I have created a new Angular2 project and installed these apps as dependencies. Now when I do npm start the Angular2 app is starting but how do I invoke the other apps…
arjun
  • 11
  • 5
0
votes
2 answers

In TypeScript, create object of same class having constructor of http

export class FloorPlanComponent implements AfterViewInit, OnInit { constructor(); constructor(public _baseComponentService?: BaseComponentService, public _internalZoneService?: InternalZoneService, …
0
votes
0 answers

Angular injected service is not singltone

I created a new angular project with two components, app component and TempComponent, and a service called TempService. I wish to inject this service to both components as a singleton. The components and the service are all in the same module and I…
RiskX
  • 561
  • 6
  • 20
1 2 3
99
100