AngularJS services are singletons that carry out specific tasks common to web apps. AngularJS provides a range of built-in services, along with the ability to create custom services as required. Services are also used for communication between application components through dependency injection (DI)....

learn more… | top users | synonyms

-1
votes
0answers
10 views

Data combined in an object is not displaying in the next view AngularJ

//CONTROLLER $scope.order = $scope.getOrderData; $scope.getOrderData = function() { $scope.order = letterCreateSrv.getOrderData(); }; $scope.savePackageData = function(data) { console....
1
vote
1answer
15 views

Same data is returned in AngularJS Promise Chaining

I want to make 3 API calls when my page is loaded to bring the necessary data. My application is in AngularJS#1.5.8. I am able to bring the data separately in service, but for some reason, in the ...
0
votes
0answers
18 views

How to return mock json object from file as service response in Angular JS Jasmine Unit Test?

I am referring the stackoverflow article How do I mock a service that returns promise in Angularjs Jasmine unit test?. And found it useful in my scenario as well. But I want to load and return object ...
-1
votes
0answers
7 views

Returning empty data from database in angular js

I am using angular js http.get method to fetch data from database with php script, but having problem when php returns empty record. How can I solve this problem?
0
votes
1answer
51 views

How to Handle multiple Ajax call calling same function?

Hi have 4 directives on the page, all directive require list of user. User List is stored in database which require hhtp request. As 4 directive are on the page at same time so 4 different ajax call ...
0
votes
5answers
33 views

Need to store Objects, so that on refresh, the object should be available in angularJS?

I have a Service implemented. And i'm creating two Objects. After refresh their values are becoming null. how should I store these objects, so that i can access them after refresh also. var userPool ...
0
votes
2answers
43 views

AngularJS - Unable to call http serrvice using factory

To resolve my issue I have gone through many articles on different sites, but none resolved it. I'm writing a simple AngularJS application. I'm quite new to Angular. I have written a factory method ...
4
votes
2answers
49 views

Angular 1 promise in service

I've been going crazy trying to get something to work in Angular 1.3 that may not even be possible... but it seems like it should be. Basically, I'd like to write a service that returns only a ...
0
votes
1answer
30 views

Use return statement twice in factory

I have a factory code where I need to return methods for use in template and also return _this for use in getting info from the controller to send off via the factory. Problem is I don't know how to ...
0
votes
2answers
42 views

unable to inject a service in controller

I am using requireJS for my angularjs app. common.service.js define(function () { var coreModule = angular.module('coreModule'); coreModule.config(['$provide', function ($provide) { $...
0
votes
1answer
21 views

Pass Array from Controller to Factory error

I have a factory thats using angular-websocket to connect with a backend and I need to pass info from my controller to it so that it would send that info and I want to pass it as an array. Factory is ...
1
vote
1answer
37 views

angularjs firebase user auth service not communicating with the views

I have a service which passes on the parameter pseudonym to the evironment. I call on this pseudonym in my views, but it doesn't appear at all. How can I fix this to display the value in my views? ...
2
votes
0answers
41 views

why a service does not receive events

I have some code that was working in a controller. I refactored and moved that functionality into a service. The code had an event listener: $rootScope.$on( .....) This was caught when it was in the ...
0
votes
0answers
51 views

Sharing data between controllers using $broadcast

To share data between controllers it is common to use service. I found that using $rootScope.$broadcast is really convenient if the data I have to share is a [] or an {}. For me the advantage of ...
0
votes
2answers
64 views

What is the best way to store key value pairs in Angular JS

I have an angular app that consists of a main page and partial pages. Partial pages are displayed in ui-view <div class="" ui-view> </div> To store a global variable I use $scope.$...
0
votes
0answers
38 views

How to send Json object as parameter to Web API using AngularJs?

I am using below angularJS code for sending Json Object to my WebApi. My WebApi is triggering successfully. Now , How to get Json Vales in WebAPi. $scope.save = function () { var ...
0
votes
3answers
53 views

Call a Web ApI method with Parameters using AngularJS

I am calling a web API with angularJS Service. My webp API method is working fine without parameters '/api/Subpart/' When i tried to pass parameters , Web API method is not firing. Angular service ...
0
votes
0answers
12 views

TypeError: dataFile.saveDataFile is not a function in angularjs service

I'm getting the error TypeError: dataFile.saveDataFile is not a function when trying to call the function saveDataFile from my dataFile service (funnily enough). The dataFile service code is below, ...
0
votes
1answer
21 views

Pass Data to Service from Controller AFTER receiving info from Server

I need to pass data to an array in service after getting from server. The controller runs the function to retrieve data as shown .controller("messagesController", function($scope, $stateParams, ...
0
votes
2answers
24 views

use values to call factory's function in angular

Im trying to call the factory function from a controller using values but im getting a TypeError Controllercode $scope.onButtonHovered = function(event){ console.log("event.descriptorName "+ event....
0
votes
1answer
22 views

Angular Service Error not returning the control to then

I have a question regarding angular service. I have a controller and a service and if in service(which is calling a backend code) and I get an error. It is not transferring the control back to ...
0
votes
2answers
35 views

Sending a Post request in Angular 1.x via factory

The post request url should be updated in the following format. https://www.example.com/api/one-push?type=json&query=push&title=____&url=____&tag=___ <form ng-submit="submitUrl()"&...
0
votes
3answers
34 views

How to correctly return my data from AJAX call (AngularJS)

I have a view that calls this function below which makes an AJAX call to our API - this for some reason always returns 'undefined' when I view this in the AngularScope using the Firefox DOM inspection ...
0
votes
0answers
27 views

Not able to inject service class to controller in Angular [duplicate]

Here is my code loginService.js (function () { 'use strict'; function loginService($scope, $http) { var userData = {}; userData.Id = 2; userData.role = 'admin'; userData.email = '...
2
votes
1answer
21 views

angularjs services with a returning test

I'm trying to create a serice in order to check if the user is connected before doing anything. the service is: app.service('generalService', function ($rootScope, ngDialog, Data, $location) { ...
0
votes
1answer
44 views

How to implement multiple instances of angular controller and allow other controllers to enquire state if each instance

UPDATE 1: I researched using angular service as suggested by @charlietfl. Based on my findings, I have rephrased the question, and clarified the details. See code parts and snapshot below to for more ...
0
votes
0answers
33 views

Displaying JSON from a server using a AngularJS custom service and TypeScript

I have a server currently serving up some JSON and a swagger definition. My goal right now is simply to perform a GET on this server, and display the response. I generated a TypeScript client from ...
0
votes
1answer
25 views

Use same ng-controller with different aliases in different parts of HTML

I'm having a problem with my ng-controllers when they are more of one in the same page. For example, I have one controller on the page header, one on another section of the same page, and one in the ...
2
votes
0answers
17 views

Passing data between angular controllers

Below is the sample code where I am trying to pass/sync the value between the two controllers. For the same in view I have a textbox and two place holders for showing the value of the textbox. I ...
0
votes
2answers
55 views

angularjs service uncaught syntax error unexpected identifier

Angularjs service which is returning my json data from web service is creating error uncaught syntax error unexpected identifier at return statement. this is my angularjs service- app....
0
votes
3answers
106 views

Pass JSON data from one controller to other angularjs

I've a login service which gives me JSON object as a response having user details. Now in this response, there's an object named permissions which gives me information about the CRUD permission ...
0
votes
1answer
50 views

Angular 1.5 component …ng-link Issue

I have nav bar Home Accounts Services Orders Tickets on click of Accounts there is drop-down with fields new Customer and Search Customer On click of new Customer it should navigate to home ...
1
vote
1answer
62 views

Typescript and AngularJS - Static methods vs services

TL;DR: Static basic functionality that has to do nothing with angular - implement as an AngularJS service vs plain static exported class / methods? Long version : I've been programming in TS for ...
0
votes
1answer
235 views

How to share variables across components in Ionic 2?

In Ionic 1 (With Angular 1), I can create a $scope.abc on the ngApp layer and other ngControllers can inherit $scope.abc with ngModel, so that when a text area in one controller changes, the others ...
2
votes
3answers
53 views

Can't get a value from $http promise and then() code not executed

I already had a problem with $http service in the past which I resolved by creating a service to handle my requests (for those who are interested, here's the link of the answer which helped me, the ...
0
votes
2answers
109 views

Creating Custom Objects in AngularJS

I would like to implement my own custom object/classes in AngularJS. However, I'm getting stuck on the concept of using factories/services as custom objects - I understand that factories and services ...
0
votes
1answer
44 views

AngularJS - Call function in service from the same service

HTML <input type="button" id="PlayOrPause" style="width:60px" value="Play" onClick='doPlayOrPause();'> Ctrl $scope.doPlayOrPause = function(){ cameraModuleService.doPlayOrPause(); } Service ...
0
votes
0answers
37 views

AngularJS Two-Way Data Binding Between Windows

I'm trying to find a way to get two-way data binding to work between windows in Angular. I'm able to successfully access data across the two windows using the object reference from $window.open(), but ...
0
votes
1answer
32 views

1.4mb data crashing browser in angular http request

I have a service that does a http request and get around of 1.4mb of json data. It makes my browser stop responding. :( MapService.measures(id).then(function (data){ console.log(...
1
vote
0answers
33 views

Angular Unit testing: how to mock server sent events

I have a angular service that wraps a server-sent events. How do I mock the server-sent events in unit testing? Can I use mockHttpbackend in this case?
0
votes
1answer
77 views

garbage collecting variables in angularjs service

I am new to angularjs. I have designed an angularJS service, which is as per the diagram given below :- Global Service is used as a mean for inter-controller communication. That's, it contains data ...
0
votes
1answer
31 views

Error on AngularJS : $injector:unpr Unknown Provider:

i'm trying to make an angular app following thinster.io tutorial(https://thinkster.io/mean-stack-tutorial), i restarted and restarted again after many erros, this is a new one : Error: $injector:unpr ...
0
votes
2answers
30 views

AngularJS using value service

have an understanding problem with .value() and the use of it in controllers... In the following example, declare the .value() in services.js : .value("ScanDatas",{ scanData: {} }) Think once ...
0
votes
1answer
26 views

Unknown Service Provider in AngularJS App

In my angularJS app, I have configured my app like below. I have defined a module services to define all of my factory methods. angular.module("services", []); var app = angular .module('myApp', [ ...
0
votes
4answers
66 views

AngularJS, how do I use a service to capture HTTP data and bind it to my controller?

I have an API call that's working great, but I'd like to use it on several controllers so I moved it to it's own service. I'm running into what looks like a classic Scope issue or a misunderstanding ...
0
votes
2answers
30 views

How can I invoke an angular service from a controller?

I have an angular module with the following code: angular.module('sampleModule', []) .service('myService', [function () { this.showAlert = function () { alert("Hello"); }; this....
2
votes
1answer
116 views

Angularjs : Using common service in different modules

I am trying to use the same service for different modules. There are many modules so i tried to inject them in a parent module. Something like this: var app=angular.module('myapp',['module_1','...
0
votes
0answers
16 views

Is it possible to have a model or data service that updates the data and triggers another service to act on the changed model

I am wondering if its possible to have a service or a directive that based on a change in a url link , the model or the data service is updated and likewise, once the model is updated , another ...
0
votes
2answers
62 views

Inject Angular factory dependency into Typescript class without polluting constructor?

I'm writing an factory as a Typescript class and instantiating it with new FactoryName() when needed. I'm getting it working as a factory by doing this: .factory('FactoryName', function() { return ...
0
votes
1answer
21 views

Service and Controller to call api with a value in the end of api

I have a service call that I want to pass a value into the function to call the http.get api by id: /home/api/order/1 My service looks like this: angular.module("app") .factory('Service', ['$http', ...