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

Need to Reload Browser to See Changes in Angular

I'm adding my data through ng-bootstrap modal but i have a problem since when i click the add button, it needs to be refresh before i can see the new added data. I already called the this.getMaterials() when i successfully added the product but it…
user8743396
0
votes
1 answer

How to use Observables for inter-component communication

I am using Observables and Subjects from Rxjs to communicate between two components, Here is the service part: import { Injectable, EventEmitter, Output } from '@angular/core'; import { HttpClientModule, HttpClient } from…
0
votes
1 answer

Angular 1: service variable getting updated via controller

I have done this before, but this time dont know what went wrong. A service: angular.module('module') .service("BaseService", function() { var vm = this; var testValue = {a:1,b:2}; vm.getTestValue = function(){ return…
Luckyy
  • 1,021
  • 4
  • 15
  • 29
0
votes
0 answers

Angular service method calling http get with URLSearchParams , but dont see querystring?

Im trying to use URLSearchParams to fill in querystring parameters and their values. However, the resulting url that seems to get used on the http call doesnt look like its including any of the querystring info. What am I doing wrong? Im looking…
bitshift
  • 6,026
  • 11
  • 44
  • 108
0
votes
1 answer

Reading API on Angular 2 Error of 'Cannot read property of "1" of Undefined'

I am having a problem with my project because I getting data from an API on a server and taking on of the objects and populating it with the data. But the problem is that the console says that the Object is Undefined. This is the output of the…
Reponic
  • 91
  • 1
  • 1
  • 8
0
votes
2 answers

Angular service not updating subscribed components

I have an Angular 2/4 service which uses observables to communicate with other components. Service: let EVENTS = [ { event: 'foo', timestamp: 1512205360 }, { event: 'bar', timestamp: 1511208360 } …
GluePear
  • 7,244
  • 20
  • 67
  • 120
0
votes
0 answers

Memory leaks due to service variables

I have an angular service having some properties and methods. This is injected in different controllers and all working fine as expected. Now the issue is with the memory conception. The signature of the class looks like the following: export…
sujith karivelil
  • 28,671
  • 6
  • 55
  • 88
0
votes
1 answer

Angular js: Radio button not visible

There are several rows present on the page, in relation to it i have placed the feature of editing values of every row after opening a modal popup, now on modal below is the radio button used for Gender.
0
votes
1 answer

How to include an angular.js service's data in a controller?

I've created a service that fetches data from the server. The browser tools confirm that the data is picked up correctly. angular. module('karassApp'). factory('Person', ['$rootScope', '$http', function($rootScope, $http){ var persons =…
Joshua M. Moore
  • 381
  • 6
  • 20
0
votes
1 answer

Angular 4 switching from hard coded data for cascading dropdowns to getting a complex object from web api call

On a new project with .net core and Angular 4 - I had to wait till a real database was in place. Now that it IS there a DBA , along with a backend developer ended up a web api that I need to call and fetch a nested object with data that I had…
user8545750
0
votes
1 answer

XMLHttpRequest Url cannot load Url No 'Access-Control-Allow-Origin' header is present on the requested resource

XMLHttpRequest http://172.ip.ip.ip/employee/record/details cannot load http://172.ip.ip.ip/employee/record/edit/12345. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost' is therefore not allowed…
user8438161
0
votes
1 answer

Get DOM element from service in Angular 4

I have root component in my hierarchy, called "root-app". Also i have router and few components, which loaded by this router. Than i have a service, which control page navigation. I need to get one element
0
votes
1 answer

Passing the data from AngularJs Service to Controller and Controller to Controller

Currently I am able to pass the value from the AngularJS Service to Angular Controller, But Now I am doing some calculation in one controller and now I want to pass it to another controller , Can you please help me Service Name :…
Mahesh G
  • 1,226
  • 4
  • 30
  • 57
0
votes
1 answer

Angular access to data outside of a method that subscribes to an observable

I want to be able to get access to data outside of my method with .subscribe This is my Service which "works" fine getSessionTracker(): Observable { return this.http.get(this._url) .map((res: Response) => { …
user8545750
0
votes
2 answers

Display Specific Detail When Click View Button in Angular 4

i need help in making this "view detail function" work. First, i had the users component which i want to imitate on how it worked. Like you have to access its service when you try to get the specific thing. But the users component is its not from…
Joseph
  • 7,042
  • 23
  • 83
  • 181