0
votes
2answers
18 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 ...
0
votes
1answer
14 views

AngularJS service error on Safari and IE (InPrivate mode)

I have a service like below app.service('abcService', function($q) { this.abc = function() { var deferred = $q.defer(); ... blah blah ... deferred.reject(object); return ...
1
vote
1answer
15 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
20 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
30 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
19 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
20 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
22 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
42 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
52 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
17 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
32 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
29 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
32 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
26 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
29 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
22 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
20 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
0answers
25 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
28 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
28 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
12 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
32 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
24 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
19 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 funtion I have written through a ...
0
votes
2answers
41 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
20 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
34 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" ...
1
vote
1answer
52 views

ng facebook with facebook comments

I am using ng-Facebook service in my angular web app. I want to include a Facebook comments plugin. So, I have copied the code in the Facebook plugin with the Javascript SDK. I can see the comments in ...
0
votes
0answers
31 views

How to modify the scope in an event in a service (factory)?

I created a factory that creates an audio tag with different audio files played. What I want to do, is to make a loading gif appears while it load a new audio file, then disappear when it is loaded. ...
-1
votes
1answer
25 views

Why AngularJS services get undefined while navigation from one route to the other?

I have an issue in AngularJS. I am trying to authenticate the user and when a response got back from the server I use a service to store the user state as he is admin or not. Till now everything is ...
0
votes
1answer
38 views

Unclear on new style of AngularJS factory notation

I was looking at this interesting piece on Angular best practices, and decided I wanted to adopt some of these ideas as my own. However, his factory notation is something new to me - I haven't seen it ...
0
votes
1answer
36 views

AngularJS 1.2.19 return values from nested $resource service

I'm fairly new to angularJS, but wrapping up a project and trying to clean up some code by moving a lot of business logic from my controller into a service call. Currently my three factory service ...
1
vote
0answers
43 views

How to prevent calling of a service when hitting refresh button

I have problem in angular. I have made a service that should authenticate the user that service has two variables which are var isAuth and var IsAdmin;which indicates the state of the user. In the ...
0
votes
0answers
23 views

Autoload service in Angular.JS

A lot of my controllers use the $http service like this: app.controller("MyController", function($scope, $http){ ... }); Is it possible to autoload services so I don't have to keep typing $http ...
0
votes
2answers
31 views

How to make angular's services available to independent objects ; Angular JS

In my angular app, I am trying to make a dataAdapter factory where I can quickly switch between the local adapter and the api adapter during development and publishing. My dataAdapter factory looks ...
0
votes
2answers
32 views

Sharing unsaved $resource between controllers in Angular.js

I have a home page that encourages uses to signup for a service. The home page only has a few inputs to fill out. After the new user submits those fields, they are taken to the primary registration ...
0
votes
1answer
34 views

AngularJS routing

I have some accounts routes: .when('/accounts', { templateUrl: 'views/accounts.html', controller: 'AccountsCtrl' }) .when('/accounts/:accountId', { //templateUrl: ...
0
votes
1answer
30 views

Trying to call method in service from a controller

I'm trying to call a method in a service from a controller and am receiving the error: 'TypeError: undefined is not a function'. Does anyone see anything wrong with how I have things set up? valid.js ...
0
votes
1answer
30 views

Persistent entities (JSON objects) in AngularJS

I'm primarily a C# and Java developer. Quite a newbie to JavaScript and AngularJS. I'm developing a web app and I want to architect the app in the following manner : Topmost layer : The views and ...