-1
votes
0answers
12 views

Ping on regular intervals in angularjs $stateProvider.state

In one of my state, I am requesting for data through resolve. Basically there are two parameters in resolve as shown below. First Resolve acts as a parameter for 2nd resolve parameter. All this ...
2
votes
2answers
17 views

AngularJS: how to modify an array in the service from multiple controllers

I want to have an array in the service, which can be modified from different controllers. The purpose of this is the have an array accessible through every controller. I want to be able to push items ...
0
votes
1answer
26 views

AngularJS a service is not a function

This current code when ran returns TypeError: Services.updateUserData.set is not a function Controller Services.updateUserData.set($rootScope.user); Services.js this.updateUserData = function() ...
0
votes
0answers
28 views

why is parent scope function always overriding function parameter of child scope angularjs

question summary: how do i make a directive child function use the parent function definition, but while using the variable that's defined within the child directive scope. i basically perform the ...
0
votes
0answers
14 views

Abstract external library in Angular

Some external libraries that I use together with Angular create global variable, which I don't really like because it pollutes global scope. For example PaperJS, when include it in the page, it will ...
0
votes
0answers
17 views

How to properly expose the results of my $http request in my service from my controller?

Right now I am passing back the full results of the $http request back to the controller. I do this so that I can show a local loading spinner, deal with any application errors returned from my API ...
0
votes
2answers
17 views

self-updating angular factory with socket.io

I'm trying to use an angular factory to provide a shared piece of state to my controllers. I also want this factory to automatically update its state by listening to a websocket. The goal is that I ...
0
votes
2answers
26 views

http.get() Gets Deserialized JSON but Returns HTTP Response?

In my Angular app I have a baseController.js class and a class exampleController.js which can access the functions defined in baseController through injecting its own scope into baseController. This ...
0
votes
1answer
53 views

Is it okay to have a function as an Angular service?

Usually AngularJS services are objects - no matter whether you create them using service, factory or provider. Now I have a use case for a singleton function. Basically, I could solve this using a ...
0
votes
1answer
19 views

AngularJS pass variable to service

I have this factory: factory('getJson', ['$resource', function($resource) { return $resource('json/greetings.json', {}, { query: {method:'GET', isArray:true} }); }]); the file is ...
-3
votes
0answers
24 views

how to pass json object between different controllers in angular js? [duplicate]

Like in asp.net mvc, we use ViewBag, ViewData, to pass in objects between different views. How do i pass in a Json Object between 2 different controllers using angular js?
-1
votes
0answers
10 views

Angular js retrieve State

I normally use service to save the view state ! But now i have a view where I retrieve data from browser database so I am Looking for a way to retrieve from data base only when the view is opened ...
0
votes
1answer
19 views

Confusion about how the promise returned by $interval works compared to $timeout in Angular

I'm having an issue understanding how the promise returned by $interval works in Angular. Let's say in the following example, we have a simple "api" factory with a method called "getStuff" that ...
0
votes
2answers
20 views

How to add a style tag to the head using angularjs directive

Hi I am allowing users to specify whether they want to print reports in a landscape or portrait format. I was wondering if it's possible to add this (see below) into the head of the web document ...
1
vote
1answer
19 views

Angular controller called twice… how to know the amount of instantiations

is a controller instantiated a second time when I declare the controller in two different DIV's? So I just want to know if the controller will be loaded twice or not like this. Tanks in advance for ...
1
vote
1answer
22 views

Angular JS - Decorate a service with the controller name

I am unclear of exactly how decorator works in conjunction with the angular $injector, so any explanation is helpful. Considering my myTempService: $provide.decorator('myTempService', ...
0
votes
0answers
37 views

Resolving dependencies of an Angular service for unit testing

Should every dependency of the module below be mocked or injected in the spec or will it suffice to include the modules in my karma.config.js? I'm using the Jasmine Framework and running my tests ...
0
votes
0answers
21 views

can controllers be separate files while sharing data between controllers through a service?

I'm doing something like this: How to create separate AngularJS controller files? But I'm trying to share data between these separate controllers using a service. I'm unable to do it. Can you tell ...
0
votes
0answers
21 views

inject $q into mockService before other services use mockService

I have a UserService which has myService as a dependency. The trouble is, within UserService, myService.getAll is called. However in my karma jasmine tests it complains that myService.getAll is ...
0
votes
1answer
23 views

How to bind to the result of a function in AngularJS

I have an array of items that I want to keep track of across several controllers. So, to do this, I made a service. The service is basic for now, just adding items to an array and the ability to get ...
0
votes
1answer
22 views

View not getting the new value

I have this service to keep the status of the app up to date. 'use strict'; angular.module('reportApp') .service('Status', function Status() { this.appStatus = {}; // Status this.get ...
0
votes
2answers
47 views

$httpProvider interceptor not working when $http is injected into a factory

I have a service called 'api', registered something like this: angular .module('myApp') .factory('api', ['$http', function ($http) { // do stuff with $http.get() etc here. }]); ... and ...
0
votes
2answers
55 views

How to get a $scope object to an angular service

I have an object that I am modifying on $rootScope where I am "storing" my last search parameters. Currently I have the values returnType, rows, and query hard coded. I would like to those just be ...
0
votes
1answer
18 views

How to organize some Utils files in AngularJS to call from app.config?

I need to configure AngularJS - set default $http headers. In my case i need to generate some of them. To make this i need to call some reusable function from Utils service. As app.config doesn't ...
2
votes
2answers
37 views

AngularJS - Design pattern for returning a subset of data from a service… and binding to the set?

I have a service that manages a set of data. The service is polite enough to provide options to return a subset of said data based on (whatever logic, in this example it's simply going to look for a ...
0
votes
1answer
32 views

angular service available at configuration phase

I want to move some of the repetitive logic out in a reusable service, which must be available in a config phase. And possibly have access to $xxxProvider dependency injections too. Is such thing ...
0
votes
1answer
21 views

How do I call a Service from my $httpProvider

I've been struggling with this all morning. I'm trying to call a Service from within my config($httpprovider). I've read a lot of people explaining that Services are not yet available during config. I ...
0
votes
1answer
36 views

AngularJS Trigger $scope.broadcast from $resource

Introduction I am trying to make sure that I am using all the parts of my angular application correctly / all the right code is in the right place. I came across this article ...
0
votes
2answers
32 views

Error injecting custom service into another custom service

Now that I have my script files referenced in my view template, I am having trouble injecting the first one into the second one. If I unplumb the dependency that LearnerService has on SCORMService, ...
0
votes
1answer
14 views

AngularJS: don't remove data until resource loads

I'm completely new to $resource so I'm not sure how to use it. (this is not the real code but it is similar) service: .factory('User', function ($resource) { return $resource(apiPath + ...
0
votes
1answer
16 views

Loading a custom service as a dependency of my Angular module throws an “uncaught object” exception in angular.js

The relevant code: var app = angular.module('client', [ 'ngRoute' ,'controllers' //,'proxyServices' ]); app.config(['$routeProvider', function($routeProvider){ ...
0
votes
1answer
30 views

How do I use a legacy javascript library as a scoped dependency of an Angular service?

Specifically, I am working with an ~800 line SCORM API wrapper library that facilitates communication with an LMS. The author did not write it in Angular. A legacy, vanilla js file(index.js) has been ...
0
votes
2answers
25 views

Building a '$resource' service for multiple API calls

I have created a factory service that can get data from an API with the following code. app.factory('Book', ['$resource','$http', function($resource, $http) { return ...
0
votes
0answers
23 views

getting : undefined is not a function on getting collection from web-api

I have a web api which returns IHttpActionResult(myCollection) on Get. My angular JS controller is has a function : $scope.loadcollection = function($defer, params) { console.log("inside ...
0
votes
1answer
32 views

Updating the data in the angularjs service and controllers

I have a angular service called 'NoteBooksService': app.factory('NoteBooksService', function() { var permanentStorage = window.localStorage; // Initializing the local storage if no data ...
-1
votes
1answer
33 views

Angular JS: how to change view in ng-view

I have navbar,sidebar and container. for each item in navbar have different sidebar. Ex: - If i click Nav A, it have sidebar A, B, C. - and if i click Nav B, it have sidebar D, E, F and for each ...
0
votes
1answer
19 views

Static data served from AngularJS Service

I have a couple relatively large javascript objects that I use to help out with data bindings, layout of the page and a lot of logic in the controller. I have moved these objects in a service. For ...
0
votes
0answers
35 views

AngularJS: window service and directive

I'm learning AngularJS and I want to create a custom service and directive to show window view which I can close, minimize, maximize, drag and resize. I wrote something but I am not sure if this is ...
0
votes
0answers
13 views

Angularjs service returning 404 on emulator/device

I'm facing issues with service method in emulator. Below is my template, which is calling a controller method 'loadFeed()' of FeedCtrl controller, which inturn calls service method parseFeed() of ...
0
votes
1answer
36 views

AngularJs DELETE with data sets wrong content-type header

I am making a $http DELETE request with a payload but the content-type is wrong. I have a data object, but the content-type is getting set to text/plain instead of application/json. As you can see ...
-1
votes
1answer
27 views

POST 404 Not found.. Angular js

here i'm sending data through $http.post to data/user.php app.factory('loginService',function($http){ return{ login:function(data,scope){ var ...
0
votes
2answers
24 views

In angularJS store the admin(id, password) by start from a json in localstorage, but angularJS didn't work

I want in angularJS store oder preload the admin(id, password) by start from a json in localstorage, but angularJS return always error. the init function I have written through a ...
0
votes
2answers
43 views

Convert String to Function in AngularJS

I am trying to convert strings to AngularJS Service method calls in a controller. For example, I would like to convert the string "Contact.send(email)" to call an existing service method. I thought ...
0
votes
2answers
23 views

calling ng-view controller method from outside controller?

HTML: <html ng-app="san"> <head> </head> <body ng-controller="sanctrl"> <div> AngularJS</div> <div ng-view=""> </div> <button type="button" ...
0
votes
2answers
32 views

Can't bind 2 objects from JSON in Angularjs?

I'm new to Angularjs. I am learning about factory. In my example, I have 2 requests to Restful Api and got 2 responses in JSON format. With the first json, I can use ng-repeat to show them but the ...
0
votes
1answer
45 views

Service not working - AngularJS

My task is to create a form and display the entered data to a div on clicking 'Submit'. The task involves creating two directives, one for creating the form and another for displaying the entered ...
0
votes
1answer
22 views

pass by ref to service

can I pass a parameter to a service by ref in angular js? for example: var img = //image object from the view MyService.ChangeSrc(img); is it possible that the src can be changed in MyService ...
0
votes
1answer
25 views

AngularJS OrderBy problems

So i'm learning angularJS and was messing around with the ng-repeat, and $http service. I picked a webservice to return some data, and put it into the ng-repeat and that all works fine. I want to be ...
0
votes
0answers
17 views

issue with return value of service in AngularJS

I'm facing issues in returning data from Angular Service. Below is the service code.... app.service('Data',function(){ var accountList = []; var currentAccount ='Test1'; //Initialization var ...
0
votes
1answer
36 views

How to $http.post with payload in data?

How do I post data from a form in AngularJS? <form data-ng-submit="doSomething()"> <input type="text" data-ng-input="do_obj.text"/> <input type="email" ...