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

angular 4 - unwanted multiple service instances

This might be a tricky question and i'm hoping to provide enough information to solve this since I'm already trying for hours. I'm pretty sure that I have somehow instantiated two services since changes initiated from one components, didn't affect…
Han Che
  • 8,239
  • 19
  • 70
  • 116
0
votes
1 answer

How to add user input dynamically to Http Call in a Service

I am very new to Angular and trying to play with the real data. I am making an API call to darksky API , well at least I am trying to do. What I want to do is ; At the beginning I have a small form, which asks from user to enter latand…
Atlas
  • 241
  • 3
  • 19
0
votes
2 answers

Delete Item In Angular 2

How will be able to delete item in Angular 2+? I am new to Angular and I'm confused a little bit about this. Hope you guys can help. I just did the add item by the way but i don't know how to delete an item. I am using three files here below. 1.…
Joseph
  • 7,042
  • 23
  • 83
  • 181
0
votes
1 answer

Passing parameters in angular4 services

I have been trying to pass two parameter from my angular frontend to node api. However I am getting error on my node console that paramter value is missing or invalid when I run my app. Below here is node api code app.post('/users', function(req,…
mohammad obaid
  • 415
  • 4
  • 16
0
votes
1 answer

Angular2 - Call service multiple times

Is there a way to call a service multiple times? I want to load some data from my DB and in case its a long list, I want to load 1000 entries at each request, if I do something like: while (!done) { ... } I will get to many requests to DB that…
João Silva
  • 531
  • 4
  • 21
  • 40
0
votes
1 answer

Angular 2 Error while fetching data from Django Rest API

I'm new to Angular and I'm creating a test Application to accelerate my understanding of the topic. Recently I encountered a challenge to integrate Angular2(FrontEnd) with Django(Backend) by fetching the data using REST APIs. File:…
0
votes
1 answer

What is the best way to filter/sort or manipulate data to be presented in angular 2

I have a set of resources (in JSON format) that I receive from a service. The resources have properties like name, which operator they belong to, status, power flow etc. First I select the operator from a drop down, or the status of the resources…
Nitz1308
  • 25
  • 1
  • 9
0
votes
1 answer

How to share services - NgModule - Angular2

I know that in Angular2, services provided by a module are available to other modules and should be provided only once. I have a lazy-loaded MessengerModule which imports a MessengerService. I have also a HeaderModule which needs this service only…
Mathieu Kb
  • 23
  • 4
0
votes
2 answers

Angular4 - why does promise from service resolve to undefined?

I'm wrestling with an undefined return from a promise. From my detective work, it seems that the problem is assigning the results from the promise to a instance variable on the component where I am calling the promise. I think it is a type(or…
0
votes
1 answer

Error loading @angular/common/http - angular 2

I am trying to implement a service in Angular 2. Service: import { Injectable } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { Observable } from 'rxjs/Observable'; import { BrowserModule } from…
Dheeraj Kumar
  • 3,917
  • 8
  • 43
  • 80
0
votes
0 answers

GET http://localhost:4200/api/user/ 404 (Not Found) angular 2

I have this error when I try to login to my app but i have some problems with a 404(not found) included... I will put some lines of my code and the image of the error..... Please help me fix the issue . @Injectable() export class AuthGuard…
0
votes
2 answers

Angular 2/4+ Shared Module: To forRoot() or not to forRoot()

Ever since digging past the first few basic levels of Angular dependency injection (DI), and striking the gem that is forRoot(), I have been wondering exactly what the best practices are for actually using it. I stumbled across the method while in…
joshrathke
  • 7,564
  • 7
  • 23
  • 38
0
votes
1 answer

cannot pass the input field value to service in Angular 2

contact-bar.component.ts saveContacts(): void{ var contact = new Contact({}); contact.id = 1; contact.name = (document.getElementById("contactName")).value; contact.mobile =…
Om Patel
  • 227
  • 1
  • 3
  • 9
0
votes
1 answer

Module with Providers as a package dependency on node_modules

I have a Module with Providers in a package dependency. But when I try to use it in my app.module I get: Error: No provider for EnvService! /node_modules/common-components/env.module: import { NgModule, ModuleWithProviders } from…
Marcio M.
  • 371
  • 1
  • 6
  • 15
0
votes
1 answer

#Angular2 How i can count numbers of custom attribute directive?

I made a custom attr directive and i will use it in siblings elements like:
1 2 3
99
100