Tagged Questions
0
votes
1answer
38 views
Is this an appropriate use of an AngularJS Service?
I have an app with many views that are varied and numerous enough to justify dynamically loading CSS files, based on which view is active at the time.
I looked into various ways of dynamically ...
0
votes
0answers
26 views
How to send data back to angularJS controller when full data is not fetched yet [on hold]
I have one logical question and the scenario is:
I am using AngularJS and Spring 3.
When user click on say "show all results", from controller to service and a rest call to spring controller is ...
0
votes
0answers
13 views
AngularJS - Multiple $resource in a service
I have a question not sure if anyone could understand my requirement... The code below is what I currently do to get a resource form a service:
return ...
0
votes
2answers
22 views
ng-book examples not working as expected
I'm currently reading through ng-book for angular js and have come accross two example pieces of code.
The first deals with the $parse service and can be found here: http://jsbin.com/UWuLALOf/1/edit
...
1
vote
1answer
13 views
AngularJS Defining a helper function for private use in a service
I have an angular service that has one function visible to the controllers using the service. ie. getData
I want my service to be able to use a helper function called modifyData in the service that ...
1
vote
1answer
36 views
angularjs: Sharing model between controllers
I'm climbing my learning curve in angular.js and try to understand where to put everything.
In this case I want to know if it is a best practice to use services to share the model between ...
2
votes
1answer
34 views
Error in fetching records in angularjs
I am Trying to make code for fetch records in angularjs but didn't get any solution please help me
<div ng-app="" ng-controller="customersController">
<ul>
<li ng-repeat="x in ...
0
votes
1answer
17 views
AngularJS: $timeout within directive's controller using “this”
Not sure if everything is wired up here correctly. The objective is to call the nextSlide function, for it to change the class, wait a second, then incrament the current picture by 1, and then change ...
0
votes
0answers
35 views
AngularJS testing: Mocking $httpBackend - Handling Success and Error Methods
Update: I managed to further narrow down the problem scope and fix the Unexpected request error by updating the httpBackend.when request which contained some invalid ascii characters.
I have attached ...
0
votes
1answer
16 views
Ensure the proper order of subsequent HTTP ajax calls in AngularJS
Assume we have a super simple search form with autocomplete which triggers a $http.get() request on keyup/keypress:
<input type="text" ng-model="keyword" ng-change="makeRequest()">
and
...
0
votes
0answers
36 views
angularjs modal with data binding
i have to create a modal window for adding information to current controller. i used pop modal window using modalService. i'm just passing basic information.
$scope.saveCustomer =
function ...
0
votes
1answer
18 views
AngularJS $provider and $injector and bootstrapping
I've been trying to get into the nitty-gritty with angular DI and really the bootstrap process at large, and I am a bit confused as to where things really happen. In my mind, the events are in this ...
0
votes
0answers
16 views
Passing params to $resource query or get
I am trying to pass some params to a resource call to get only the votes matching those params
It seems to be ignoring those params on a query because it just returns all of the votes regardless of ...
0
votes
0answers
24 views
Override angular services during config phase for Live/Mock feature with the same app
I am trying to get my angular application work in live mode as well as in a prototype mode just by overriding the services. As a part of this when the prototype mode is turned on in the config, i halt ...
0
votes
1answer
29 views
Resource interpreted as Script but transferred with MIME type text/html when inject angular-route.map
What could be the cause of error in dependency injection of ngRouteProvider
NOTE: $location has a dependency on ngRoute, thats why I need to inject it, while, I am not really using it, but $location ...
0
votes
2answers
23 views
How to share ajax returned data between two controllers
Hi i have two controllers and in one i have defined some function to get me a data,i stored the data in $scope.data1, now i want to access this $scope.data1 data in some another named controller so ...
0
votes
3answers
25 views
AngularJs - Pass Values from view to controller then to service
I have looked at similar questions, but all don't make sense.
I have we api that i am going to use to login people. They provide the username and password, and then i query the api which returns data ...
0
votes
1answer
18 views
AngularJS view not rendered with data received in a service using routeparams
I am trying to show single trail information on trailDetails.html when I click this link on my searchTrails.html. And there is nothing on trailDetails.html. But if I move codes in getDataService.js to ...
0
votes
2answers
36 views
Stop Request in angularjs interceptor
How can I stop a request in Angularjs interceptor.
Is there any way to do that?
I tried using promises and sending reject instead of resolve !
.factory('connectionInterceptor', ['$q', ...
0
votes
0answers
25 views
Best way to handle configuration in AngularJS
Right now I have a service that runs and is injected into almost every single controller that provides a different API version string and URL string for requests based on $location's information as to ...
1
vote
1answer
41 views
How to close Angular UI Modal from anywhere
I am using the Angular UI bootstrap modal dialog and create it within a service:
myApp.factory('ModalService', ['$modal', function($modal) {
return {
trigger: function(template) {
...
0
votes
2answers
21 views
Get Post Response in Service
i am trying to post my form data via service but if i am trying to get the response in console i am finding undefined can you suggest me what mistake i am committing,
i am new to angular so finding ...
1
vote
1answer
28 views
AngularJS, Using a Service to call into a Controller
I am new to Angular, what I would like to accomplish is: From a Service / Factory to call methods directly into a controller.
In the following code, I would like from the valueUserController I would ...
1
vote
0answers
33 views
Angularjs factory/service management
We are working on a large scale application based on angularjs, now based on some best practices we develop a model using factory services, such that it can be shared across controllers. Since, we ...
0
votes
0answers
16 views
angularjs - $resource cookie phpsessid changes every server request
I use $resource to login to a (Yii) php backend. After the login I want to retreive all cars (for example). BUT the received cookie, contains a different PHPSESSID every request. How can this problem ...
0
votes
1answer
27 views
How do you inject dependencies into services in angular.js?
I'm using AngularFire to create a web app. Several of my controllers use a lot of the same functions to access the data in Firebase, so I am trying to write a service so that I don't have to rewrite ...
0
votes
1answer
18 views
view not updated when using $http in service
I have an angularJS application with 2 controllers and one service to exchange data between controllers.
Controller 1 "controls" an angluarjs-map an provides the map-metadata for the view.
A ...
0
votes
1answer
39 views
AngularJS why can't I use share a provider with another module?
I have a App module that has many component modules that are injected into the App module. The App module has a provider that I would like to use inside of the component modules, but I am receiving an ...
0
votes
2answers
44 views
How to stop execution of Controller with $routeChangeStart in angularjs
I am setting session on login and after that I am preventing LoginCtrl to be called as it is resetting session.
I have a setup of routes where if any undefined route is called it takes to /login But ...
0
votes
0answers
22 views
Cyclic update of AngularJS service's data
I have a chat application and a factory that implements message collection. Some message properties should be recalculated in real time (like "timeago" mark, etc.) It's a bad idea to perform such ...
0
votes
2answers
41 views
Fire event from a service without “polluting” the $rootScope
I'm building an app in angularjs, where I have a central notification queue. Any controller can push into the queue and digest the messages.
I have built a service like:
...
0
votes
1answer
26 views
AngularJS, ngResource, Service and multiple controllers. How to keep data synchronized?
I searched a lot about this, and although I found some similar problems, they are not exactly what I want.
Imagine this kind of code:
angular
.module('foobar', ['ngResource'])
...
-1
votes
0answers
23 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 ...
1
vote
2answers
26 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
33 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
36 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
20 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
1answer
25 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
28 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
44 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
63 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
24 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
26 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
11 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
25 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
24 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
23 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
39 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', ...
9
votes
5answers
4k views
Delay an angular.js $http service
I have some angular factories for making ajax calls towards legacy ASP.NET .asmx web services like so:
module.factory('productService', ["$http",
function ($http) {
return {
...
820
votes
10answers
190k views
Angular.js: service vs provider vs factory?
I'm sure this has bothered you - it has bothered me for some time now. What are the differences between AngularJS module's Service, Provider and Factory?