Questions tagged [angular-services]

Angular services are substitutable objects that are wired together using dependency injection.

Angular services are substitutable objects that are wired together using dependency injection (DI). You can use services to organize and share code across your app.

are:

  • Lazily instantiated: Angular only instantiates a service when an application component depends on it.
  • Singletons: Each component dependent on a service gets a reference to the single instance generated by the service factory.

Reference

https://docs.angularjs.org/guide/services

2054 questions
0
votes
0 answers

Service to service injection Error in Angular 4

I'm having an error with ERROR TypeError: Cannot read property 'deleteData' of undefined. It seems that my service cannot use the functions of the other service I've injected. this is my util.service.ts import { Injectable } from…
user8956707
  • 113
  • 8
0
votes
4 answers

Angular 4+ best practice HTTP service

Hello I have a quick question about using HTTP service : I would like to know if this is the right way to do. Task export interface Task { Title: string; AssignedTo: User; TaskStatus: string; } TaskService import { Injectable } from…
Kymz
  • 51
  • 2
  • 7
0
votes
2 answers

Angular 4+ httpClient best practice to use service

Hello I would like to know how to organize my code: I have a simple user interface: export interface User { Account: string; Name: string; EMail: string; PictureURL: string; Department: string; JobTitle: string; Initials: string; Skype:…
Kymz
  • 51
  • 2
  • 7
0
votes
1 answer

Can I create a service that plugs directly to my controller or maybe component

I may be wrong, but I was under the impression that I could access my service and have it display the data directly. I.e. I can inject my service and have read/write access to it from multiple components, Its easy enough to do, but if I want the…
BaneStar007
  • 377
  • 1
  • 4
  • 15
0
votes
1 answer

Angular Extends Component Interaction

My partner and I are developing an Angular 4 application where the highest level component (AppComponent) has a component (we'll call UndoComponent) that persists throughout the application. We have a router-outlet in AppComponent and for this…
0
votes
1 answer

Angular service/factory - class property not updating inside the cordova file transfer

I have Angular service that does an Cordova File Transfer upload within a mobile app - it uploads a file to media server and returns an object. I am trying to pass this object to the media_response property but i'm having no luck - what I am doing…
Zabs
  • 13,852
  • 45
  • 173
  • 297
0
votes
1 answer

error msg - is not a function when using prototype for an Angular service

I am building an Angular service for some re-usable code for an upload named 'UploadService' which gets called within a controller below - even though the service has been loaded in I always get the following error `UploadService.upload is not a…
Zabs
  • 13,852
  • 45
  • 173
  • 297
0
votes
0 answers

Angular4 service with angularfire2 loss data after navigation

I'm using angularfire. When I get data for first time it works OK and data is displayed but when I navigate to another page and then comeback to the same the data is lost unless I change something in firebase database or reload page. So, what am I…
Moises J
  • 11
  • 3
0
votes
0 answers

Query regarding Localstorage and Sessionstorage in Angular2

Is it safe to save token in sessionstorage, which I get from service call in angular2? I was used localstorage, but it can be hacked. If I simply write token from login page to localstorage manually in the browser, it automatically logins, which is…
0
votes
0 answers

ERROR Response {_body: "JSONP injected script did not invoke callback.", status: 200, ok: true, statusText: "Ok", headers: Headers, …}

In my HTML I have a button which triggers a request to an API which is supposed to request a list of users, preferably using Json. //html
senthil
  • 11
  • 5
0
votes
0 answers

Where to store in-memory app info - Angular

In my Angular app I want to store a whole bunch of data for my user, in memory, to be used in many places throughout the application (so that I don't have to make extra calls to the server). Examples of what I have to store: User's personal info…
0
votes
0 answers

Angular 4 Download/Print to PDF

I'm confused on how would i use this package https://www.npmjs.com/package/ng-pdf-make so i can print/save my page in PDF format. Can anyone help me out in using this package? If i have this "section class" in my code, how would i able to…
user8743396
0
votes
1 answer

One service for all the components

I am using a pattern in which storing all the data of my app in a single named main data service. After that i will subscribe all the component to this.The fact is here that all the components doesn't need all the data in the main data service. I…
sanjihan
  • 5,592
  • 11
  • 54
  • 119
0
votes
2 answers

Angular 4 / Can't retrieve data from Array by id

I am trying to retrieve an object from Array by id with the method getItem(). import { Injectable } from '@angular/core'; import { Http, Response } from '@angular/http'; import { Observable } from 'rxjs/Observable'; import…
Alexandr Belov
  • 1,804
  • 9
  • 30
  • 43
0
votes
2 answers

pass configuration parameters to services that extends a base service in Angular 2

I have a BaseDataService export class BaseDataService { public cacheKey: string; constructor(public cacheService: CacheService) {} //some methods and stuff } And some of services that extends BaseDataService: @Injectable() export class…