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
2 answers

Store data from controller to service in angularjs

Although there are many questions regarding the subject , yet I am unable to figure it out , how to proceed further. I am new in AngularJS. I want to pass data coming from API in Controller and pass it to another function. For this I know I have to…
WhoAmI
  • 217
  • 1
  • 2
  • 23
0
votes
2 answers

Angular2 sync up between service and Component

I have a "HomeComponent", that displays the user name in the UI. The user name is read from a json file using a service. I have the service provided in the AppComponent (parent to HomeComponent) and reused in…
keerthee
  • 812
  • 4
  • 17
  • 39
0
votes
1 answer

Keep common headers and use across many services in angular 2/4

I have several service in my app such as AuthenticateService , UserService to request data from the API. There are some common headers which user in most of the service functions such as authentication token and Content-Type header. I want to keep…
Hashan
  • 656
  • 1
  • 8
  • 20
0
votes
2 answers

AngularJS Service as Singleton to Storage files

I have I'm trying to write an AngularJS service which should work as singleton in storage files. There should be two methods: for writing files by key getFilesForTabId for getting saved files from setFilesForTabId I'm trying to write something…
Krzysztof Michalski
  • 791
  • 1
  • 9
  • 25
0
votes
1 answer

Logout Still Shows Sidebar and Header in Angular 4

I'm trying to create a admin dashboard. First, you will be redirected to the login screen, after successfully logging in, you will see the admin dashboard. The problem relies after i click the logout button on the header, I can see the sidebar and…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
1 answer

Cannot read property of undefined in angular karma test

I am testing a service function which makes numerous $http.get() calls. The actual function under test returns a promise. Currently, the test is failing with response is undefined. Here is the test: it('should return the list of catalogues',…
Matt W
  • 11,753
  • 25
  • 118
  • 215
0
votes
1 answer

md-table with datasource not updating on delete

I have an angular component with a material design table where objects are shown. This component gets its data via a datasource. The datasource gets its data from a http-service. The table itself can be filtered. That's my code, simplified - Feel…
phhbr
  • 2,699
  • 1
  • 14
  • 25
0
votes
1 answer

FirebaseObjectObservable return null value

I am tring to retrieve a single object from firebase it doesn't return any value instear I have this message instead "FirebaseObjectObservable {_isScalar: false, $ref: Reference, source: FirebaseObjectObservable, operator: ObserveOnOperator}" this…
RxDev
  • 295
  • 1
  • 8
  • 19
0
votes
1 answer

Can a service get access to component's template

I have two service (A and B) communicating between each others, A has to build a chart when the other one received asynchronous datas (those datas are used somewhere else, so B is independant). I've tried to shift what I do with the component A into…
0
votes
2 answers

This method always returned an undefined value

The service actually get a right value from server (e.g. 1 or 0), but always returned an undefined value when I implemented the service in component. I think the return statement had just compiled before the .then() compiled. How can I fix this…
Aldi Unanto
  • 3,626
  • 1
  • 22
  • 30
0
votes
2 answers

Load Up Items in Form For Editing in Angular

i need help in my editing function. I need to load the items to the form when i click the edit button. This is how my app works, first, there is a list of users, then you can click the "view more" button of that specific user and it will redirect…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
1 answer

Angular service on startup and requests dependency

I'm working in angular 4 and I have an appConfigService that provides the url of the api application from an settings.json file, something like: private appConfig: AppConfig; constructor(private http: Http) { this.loadConfig().subscribe(e =>…
Faz
  • 61
  • 6
0
votes
1 answer

Edit Item in Angular 4

Can anyone help me in my editing function. I am confused on how to make this work. I've done my best on my codes below but i can't get it. I already loaded the items in the input but i can't update a new one. I mean i don't know how to override the…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
4 answers

ng2-toastr not applying proper css when invoked in Angular 4.3.6 service

I am trying to implement ng2-toastr in my application. I am on "@angular/compilercli": "^4.3.6",. I have the following Interceptor to intercept errors form the Http. export class InterceptorService implements HttpInterceptor { constructor(public…
Dinesh Devkota
  • 1,417
  • 2
  • 18
  • 45
0
votes
1 answer

How Inherit from a baseComponent Angular2?

I am building a angular project. I want to create a BaseComponent with common functionality. For example: I have a TeacherIndexComponent: @Component({ selector: 'app-teacher-index', templateUrl: './teacher-index.component.html' }) export…
1 2 3
99
100