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 ...
2
votes
0answers
26 views
AngularJS service storing and updating data
I have a simple app that shows a list of people each with a link to an edit controller. The edit controller gets the person by id. Once the edit form has been submitted, the page is redirected back ...
1
vote
0answers
33 views
How can I listen for dependency injection inside an angularjs service?
I am attempting to write a service for angular and would like to perform a function inside my service each time I inject it into something else (in this case, to keep track of certain data that will ...
1
vote
0answers
31 views
Restangular update call when options change
My services.js
angular.module('myApp.services', []).
factory('MyApi', function (Restangular) {
var options = {quran: 210, content: 217, audio: 1};
var callBack = 1;
return {
...
1
vote
0answers
379 views
clear all pending $http requests and reload page in angularjs
i tried $route.reload(); location.reload(true); $window.location.reload(true);but pending requests are not cancelling/aborting, page is reloading, how to hard reload page means closing all $http ...
1
vote
0answers
89 views
Pattern? Encapsulating an array in an AngularJS service
I have an AngularJS service that is keeping track of an array of items, which are added and removed through exposed methods by several controllers. Surely, the view should always have the latest data.
...
1
vote
0answers
33 views
PersonController issues
Following is the code of my person controller
demoApp.controller('PersonCntrl', function ($scope, $route, $location, Person) {
$scope.newPerson = {};
$scope.createdPersons = Person.getAll();
...
1
vote
0answers
453 views
Using Angularjs $http in browser console
I've testing AngularJS services in browser console during development for quick verification. The way I inject a service into console is as describe in this question or
var $inj = ...
1
vote
0answers
86 views
Virtual URL in angularJs with routeProvider
I have a list of items app/#/items, and a form to filter the item by the location that it's located in.
I use dirty checking to trigger a method of a service that communicates with the Backend and ...
1
vote
0answers
397 views
AngularJS - “10 $digest() iterations reached” when ng-view ng-repeat dependant on $routeParams
I am really new to Angular and this is the first time that I am dealing with routing, so please excuse me if my questions are a bit confusing. My actual logic and structure for this app is much more ...
1
vote
0answers
271 views
AngularJS: What is proper way of serving async AJAX request without $http
Assume we have some service that fetch data from server. It's async and is not using AngularJS $http service.
When we deal with async stuff in Angular - we use $q promises. But there is one problem: ...
0
votes
0answers
12 views
Attempting to implement simplified pdf.js viewer within Angular app to no avail
I have identified a very stripped-down version of the viewer for pdf.js that I would like to use within an AngularJS application I'm writing. This stripped-down version has a demo available at ...
0
votes
0answers
58 views
Angularjs Service Scope + Bindings
I am looking to run the following controller but im having trouble with scope.
I have a service that calls two functions that retrieve meta data to populate scope variables.
The issue is that ...
0
votes
0answers
9 views
Using AngularJS resource with restAPI Expected response to contain an array
Quite new to angular I'm experimenting with CORS together with AngularJS
At this moment I have a service which points to a remote API
angular.module('oc24App')
.service('Oc24service', ...
0
votes
0answers
26 views
Share data between directives
I'm rendering a large form that is described in a json file, in my view I'm using ng-repeat and then sending each element to a 'master' directive called FormRender, I have a controller in this ...
0
votes
0answers
71 views
How do I add a custom method to a restangular service?
I have a decoupled Restangular service which I'd like to attach a custom method to. It appears that the only methods returned on a collection by default are getList, one, and post. I would like to do ...
0
votes
0answers
24 views
AngularJS - Updating data from resolve function (routeProvider)
I have an abstract state and other states that inherit from it.
state.general (abstract)
|----------->state.general.list // It will list a collection
|
|-----------state.general.view ...
0
votes
0answers
42 views
Workout on restful services for single page applications
I am just a beginner in Angularjs. I have been trying for consuming WebApi service by angularjs. I am following this
1: ...
0
votes
0answers
19 views
AngularJS routing depending on a service
I have implemented a service which has a function with a callback.
Depending on positive or negative callback my controller should do different routing.
The callback function gets called correctly but ...
0
votes
0answers
77 views
Angularjs reset state of factory
I have a service that makes a GET request and passes a start param. The start param is incremented within the factory
this.start++
When i click on a link the service needs to make a request but ...
0
votes
0answers
39 views
How to handle many to many relationships with Angularjs' $scope variable
I have two services that hold my two objects which have a many to many relationship; Missions (or steps/actions) and the Tools needed for these Missions. Each Mission can use many tools and each Tool ...
0
votes
0answers
20 views
Angular location change resetting browser history
I'm watching for a change on $locationChangeStart, if the user is on Step2, and they try to go to Step1 via the browser back button, I have successfully interrupted this, displayed an alert, and will ...
0
votes
0answers
24 views
How to lazy load panel content on a button click having multiple panels on the same page using angularjs
I have a scenario here where I have multiple panels (using ng-repeat) on the same page. Each panel have a link, on click of which it loads data specific to that particular panel and returned response ...
0
votes
0answers
28 views
How to test cookie Getter and Setter with Jasmine in AngularJS
I have a service with getter and setter for cookies:
angular.module('vibe.services').factory('CookieService', [function() {
var setCookie = function(cname, cval, exdays) {
exdays = ...
0
votes
0answers
86 views
AngularJs facebook login service
I am working on a simple facebook login, but I think I have a lack of knowledge about services in angular.
This is the service
// UserService
services.factory('UserService', ['$http', ...
0
votes
0answers
26 views
Creating a service with $resource as a class
I have an AngularJS service to communicate about things with my REST API.
services = angular.module 'MyApp.services'
services.factory 'Things', ['$resource',
($resource) ->
r = $resource ...
0
votes
0answers
30 views
Why do we need Angular $resource “get” and “not-get” actions?
AngularJS documentation (https://docs.angularjs.org/api/ngResource/service/$resource) states that:
**The action methods on the class object or instance object can be invoked with the following ...
0
votes
0answers
55 views
angularjs on loadmore append to existing model using ng-repeat by caling a service
I have a profile page where in the model is loaded by a call made through a service via php that returns profiles, on click of load more how do I push data to the existing model and update the data.
...
0
votes
0answers
25 views
ng-resource: setting custom headers
I'm trying to set a Authorization header but it's not working. I tried both global and local header change
var apiURL = 'http://0.0.0.0:8080';
var apiService = angular.module("apiService", ...
0
votes
0answers
32 views
AngularJS remembering page scroll location
I have multiple pages of data that lists publications by author. The first page lists all the publications and has infinity-scrolling implemented.
Another page allows you to filter by author, and ...
0
votes
0answers
31 views
$http service does not invoke error function on timeout in IE6
On IE6, when request is sent using $http and timeout occurs, error (or any other callback) function is not called.
I am running following code with Angular JS v1.0.7
$http({
url: ...
0
votes
0answers
27 views
Injecting an annotated Service in a Provider in Angular
I would like to use a Service in a Provider. I'm not sure it's the right way to go.
I've managed to instantiate a service in a provider, by injecting the service provider instead, and calling its ...
0
votes
0answers
16 views
Is service dependency mandator if implementation enviroment contains the dependency (I.E controller has dependency)
Is a dependency added to service when it will be used in a controller with the dependency already injected.
The service :
myServices.factory('firebaseWritejournalUser',['',function() {
...
0
votes
0answers
25 views
Is there a better way to inject angular services dynamically?
I'm looking to make an easily extensible system for adding 1..n datasources for an angular app.
Right now I have to do it like this, which is a bit of a pain:
...
0
votes
0answers
27 views
Share one function in one service to the second service in angular js
I have a module in AngularJS. I have two controllers (app.factory) who help to the module in validations etc.
I have one function of validation in controller 1 and i need it also in controller 2.
...
0
votes
0answers
32 views
Angularjs data call with retries
I am trying to create a provider that will be a wrapper for $http, and if a call to backend will fail it will retry (configured amount of times) before doing a deferred.reject().
There is fiddle link
...
0
votes
0answers
176 views
AngularJS $http service never calls the error handler
I have this code:
$http
.post('/api/login', $scope.user)
.success(function (data, status, headers, config) {
// code
})
.error(function (data, status, headers, config) {
// code
});
It works, ...
0
votes
0answers
274 views
excel file not getting after returning from Angularjs Service
I have situation where i have to call angularjs service method to post data to C# controller which in turns return me excel file which i want to save.
here is code....
HTML :
<div ...
0
votes
0answers
20 views
Random path for $resource in factory
I have such code in services.js for AngularJS app
factory('Agent', function($resource) {
var Agent = $resource(get_random_server() + '/agent/show',
{ callback: 'JSON_CALLBACK' }, {
...
0
votes
0answers
124 views
Persisting reference data model in the factory service in Angular JS
I am very new to Angular js.I did my research on how to persist model data but I am stuck here now.As u can see in the code below I have a reference model of basically 2 variables x n y which I pass ...
0
votes
0answers
156 views
Unable to read Angular js $http.post from Struts action
I am Trying to post data from angulajs and read it in struts action class.
Angularjs code is
$scope.dkPostData=function(){
$scope.myData={name:'Ramesh',class:'XII',Marks:'90%'};
...
0
votes
0answers
141 views
Getting error when trying to use translation using angular-translate
In my application i am trying to use localization featrure and for that I am using angular-translate.js . When I am trying to configure the translation using a static JSON file , I am getting the ...
0
votes
0answers
46 views
delay application run to resolve some defers
In my app I've got several services that keep their state in async storage, so before app starts and any directive/controller can use them I need wait until that state to be resolved from storage.
...
0
votes
0answers
49 views
Angularjs access a service without injection?
Hi I am trying to build configurable components/directives. This directive will basically accept objects and populate itself. I want to pass the name of the service that will pass the json object to ...
0
votes
0answers
59 views
Getting beyond simple data receiving $q- and $http-based factories in Angular.js
There’s plenty of information on how to get going with the $q and promises in general. But it’s quite hard to find any best practices on how to manipulate the data after it has got into the client.
...
0
votes
0answers
57 views
Clear form after submit and disable form in angular service
I create a service to upload content.
it takes 4 argument
which folder to update
the content
set the form to disabled
clear form after submit
create: function(folderID, text, o, master) {
...
0
votes
0answers
34 views
Services naming in AngularJS
I have a lot of modules with lot of services.
Im trying to invent naming convention for my services, but not sure how to do it in the right way.
My idea is to name my services like ...
0
votes
0answers
98 views
Make sure some object is loaded from server before $locationChangeStart event handler gets executed
I have a handler bound to $location's $locationChangeStart event. Within that even handler, some user object coming from the server is required. Below is the code (simplified) that I have:
...
0
votes
0answers
57 views
Angular $q.defer breaking after moving to 1.2
I have this Angular snippet which was working fine under Angular 1.0.8. I just switched to 1.2 and now, although I don't see any errors, I get no objects in the html.
// --- CONCERNS FACTORY --- //
...
0
votes
0answers
93 views
Send headers with GET request in a resource object
I need to send headers with a GET request to get content to return in a JSON format.
Specifically, I need to send Accept: application/json.
How would I add headers to this request when calling the ...
0
votes
0answers
103 views
Jsonp service works the first time but not the second in AngularJS
So Have created a service that just makes a jsonp request and returns itself. It works for the very first request, say for cat but after I try and make another request I get,
ReferenceError: cat is ...