Tagged Questions
0
votes
2answers
20 views
Passing argument(s) to a service in AngularJs
I am trying to configure my first tidbits of the AngularJs for a trivial stuff, but unfortunately unsuccessful at it after considerable amount of time.
My Premise:
Users select one of the options ...
1
vote
1answer
32 views
Angularjs - equal sign in $http post data
I'm using angularjs' $http service to post data to my API. It works great.. until I add and equals sign to the contents of data (JSONRequest in example)
var request = {
'method': 'POST',
...
1
vote
1answer
37 views
Best practice for modifying data in a method from the view in Angular.js
I'm writing an angular app to display reports which can open and close with bootstrap collapse accordions. I decided to add some view specific values to my report object for the accordion, like this:
...
0
votes
0answers
33 views
How does services created with .factory behave when I need updated data everytime on some event
I am trying to populate a table using
$resource(ng-resource)
to fetch data based on the clicked button(different params are passed for each button to resource custom service). Same service is ...
0
votes
2answers
35 views
Angular service wire up not working
I have written a service, depending on an other service. But initialisation is not working.
You can find a plunker as showcase
Should be close to working... Any tipps?
Thanks in advance!
edit: The ...
1
vote
2answers
22 views
AngularJS - computing CSS class using plain javascript or a service?
Let's say we are fetching some data from the server.
data = {
"value": "123456",
"included": true,
"invalid": true,
"warning": false,
"error": false,
}
Depending on the booleans state, the value ...
0
votes
1answer
14 views
AngularJS - Changing a template depending to a service
I am fairly new to Angular and I find it quite difficult to think the Angular way.
I have registered a SessionService which loads a user object at login. Each controller can depend on the ...
0
votes
1answer
45 views
AngularJS: Ideas for keeping DRY when calling REST and producing easy readable code, store endpoints in a js object?
I have been hacking away and currently have quite a few controllers that are calling my backend services, currently I have entered the endpoints directly into the controllers and the URls are stored ...
0
votes
1answer
19 views
angularjs global timer for inbox
Hi I'm building an angularjs app that has a timer throughout the application. Every minute I will be polling the server to see if a user has gotten a new message in their inbox.
I was wondering what ...
0
votes
4answers
41 views
Mandatory service initalization in AngularJS
I am new the AngularJS, and I am trying to do something which sounds a bit trivial but I am struggling to decide what is the best approch.
I have a service in AnuglarJS which handle all of my REST ...
0
votes
1answer
48 views
Data stored in service cannot be retrieved later
I'm just getting started on angular, and I feel like a few details are preventing me from getting this to work right!
I set up a simple service like this:
mySystem.factory('userAcsService', ...
0
votes
2answers
40 views
Initializing AngularJS service factory style
I have a service that retrieves data via REST. I want to store the resulting data in service level variable for use in multiple controllers. When I put all the REST logic directly into controllers ...
1
vote
2answers
54 views
How to globally resolve a dependency (preload current user from server)
I know I can resolve certain dependencies for a controller based on the route. However, I have a service that I always want to be resolved: The current user.
The service basically does a get request ...
5
votes
2answers
162 views
Angular Resource - how to check if a resource instance has any unsaved changes?
I want to be able to tell whether an $resource instance has been modified by the user - that is, whether its current state is different than what has been initially loaded from the server && ...
0
votes
2answers
34 views
calling function containing `$http.get()` on button press
calling function containing $http.get()
$scope.storeDb = function() {
$scope.url = '/some';
$http({method: 'GET', url: $scope.url}).
success(function(data, status, headers, config) {
...
0
votes
1answer
48 views
AngularJS service retry when promise is rejected
I'm getting data from an async service inside my controller like this:
myApp.controller('myController', ['$scope', 'AsyncService',
function($scope, AsyncService) {
$scope.getData = ...
0
votes
1answer
46 views
Calling service function on resource success callback in AngularJS
I have a service that make a REST call. When the rest call is complete (i.e. the data is available), I want to call the service's function which process that data.
.service('EventService', ...
1
vote
1answer
46 views
Temporarily deactivate button until a certain service function resolves using a custom directive
I would like to disable a certain group of buttons that are available(I am using ngClick on those buttons) only for active users, and enable them again after the request that verifies that the account ...
0
votes
3answers
57 views
Angular JS - How to safely retain global value “extracted” using a service
I need an object to be globally accessible all throughout my Angular application, and I've gladly put this object in a value service.
Unfortunately, this object is computed by another service, and ...
0
votes
1answer
63 views
Share data between angular-js controllers with service and restangular
I'm new to angular and I'm still struggling with services, I have an application that queries the server for a survey, and shows the survey questions in a wizard, each question in the survey is in a ...
0
votes
1answer
38 views
Angularjs - Digest Loop/Repaint timing
having a small issue with AngularJS. See the following:
$http({method: 'GET', url: 'some/url/withJSON.json'})
.success(function(data)
{
$scope.data = data
...
1
vote
1answer
206 views
How can I define an AngularJS service using a TypeScript class that doesn't pollute the global scope?
I am using AngularJS and TypeScript. I want to implement an AngularJS service using a Typescript class, like this:
class HelloService {
public getWelcomeMessage():String {
return "Hello";
...
0
votes
1answer
60 views
Build a reusable factory angularjs
After I decided that $resource was not my thing, I wanted to write my own factory to play with my data. Having half written this first one, I am now trying to figure out the best way to reuse this ...
0
votes
2answers
56 views
How can I get a service to access server data via an $http call?
I make an $http call inside a service that is supposed to get data from my server. For some reason I can't get my service to work - nothing happens. I know the server code works because if I place the ...
0
votes
1answer
34 views
Combining GET and POST as get and save in AngularJS service
I've got a service that gets details for a certain user profile:
.factory('UserDetails', function($resource, $rootScope) {
return $resource('../html/app/user_details.json', {}, {
query:
...
0
votes
1answer
64 views
Why can't I access a method inside AngularJS service after “then” promise? (see code)
I get the following error: TypeError: Object [object global] has no method 'setApiToken'
angular.module("userService", ["restangular", "angular-cache"]).factory "userService", (Restangular, ...
0
votes
1answer
36 views
ngModel' deep objects creation mechanism
I want to use angular' mechanism for deep property nesting , something that ng-model directive is using. I mean we can create very "deep" object in a scope by writing : ...
0
votes
2answers
43 views
Angular how to deal with unavailable URLs requested by $http.get or $http.jsonp, which are executed by $q.all()
I've the following code:
eventResourcesCall = $http.jsonp('https://apicall/to/serverA');
eventsDetailsCall = $http.get('https://apicall/to/serverB');
$q.all([eventResourcesCall, ...
1
vote
1answer
43 views
JSONP request in AngularJS doesn't work like in jQuery
I would like to request the Dailymotion API with the $http service of AngularJS, but it doesn't seem to work like in jQuery.
var url = ...
1
vote
0answers
29 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
1answer
69 views
Return local variable in one function to another
I'm building an offline HTML page using Angular and using ydn-db for offline storage.
I have a database service like so,
demoApp.SericeFactory.database = function database() {
var database = {
...
2
votes
2answers
57 views
Firefox sending multiple XHR requests when binding a controller function to the DOM
I have the following function in my controller:
$scope.model.listApplicantStatuses = function(){
var statusChoices = jobsService.getApplicantStatuses();
if(statusChoices !== null)
...
4
votes
1answer
198 views
AngularJS Directive not able to access isolate scope objects
I am trying to put some default values in my directive with Isolate scope. Basically, I need to do some DOM manipulations using the scope object when my directive is bound. Below is my code:
...
0
votes
2answers
45 views
How share Service dynamic data between Controllers and Directives
I'd like to know what pattern to use, if I need my Service to share it's dynamic data between Controller, Directives, etc. The reason I mention dynamic, is because I'd like to load new data and this ...
0
votes
1answer
62 views
How to create reset() method in Service that return promise?
I've got a service called MyArticles. Using $http GET, collects all articles for a given Category. The MyArticles Service is injected in ControllerA, ControllerB, ControllerC, that should run some ...
-1
votes
2answers
60 views
AngularJS code in a
I am new to AngularJS and managed to get this to work. Can I get some feedback if this is done in an "Angular way?"
The DataResults Service just fetches some JSON data and will eventually have more ...
1
vote
2answers
55 views
Error in LInking service and directive in Angular
I have an issue at linking service having http to a directive. This is the code of that...
myapp.factory ( 'autoCompleteDataService', ['$http', function($http) {
return {
getSource: ...
0
votes
0answers
48 views
using cacheFactory in service for CRUD
I want to create a prototype for an application and I don't want to call rest services to retrieve data. For this, I want to create my objects in services (cache) and to use these services to display ...
0
votes
1answer
74 views
Angularjs promise with jquery ajax
The factory sends data to the server and its processed correctly but after that the ".then" in the controller is not being called below.
Kindly let me know why the "then" part is not being executed ...
0
votes
1answer
105 views
Binding an array of json results to html in angularjs
I'm pretty new to angularjs, and getting a json result set that I'd like to display. I have the following;
Service:
var Post = function(data) {
angular.extend(this, data);
}
Post.getAll = ...
3
votes
2answers
104 views
Angular directive not picking up service data
My service NavData
angular.module('navData', []).
factory('NavData', function() {
var navData = {};
navData.depth = 0;
navData.category_id = "";
...
0
votes
1answer
251 views
Unknown provider CookieStore
I am having service where I want to use the $cookieStore module. It works fine, but when unit testing it breaks, and gives the error: "$cookieStoreProvider <- $cookieStore <- filtersService".
...
3
votes
1answer
370 views
AngularJS: when to use service instead of factory
Please bear with me here. I know there are other answers such as:
Angular.js: service vs provider vs factory?
However I still can't figure out when you'd use service over factory.
From what I ...
4
votes
1answer
168 views
The better approach to design AngularJS services
I'm writing an AngularJS client application that would interact with a REST server.
To manage the client / server interaction I'm using the $resource abstraction.
Actually I'm writing every resource ...
1
vote
2answers
359 views
Firebase's AngularFire in an AngularJS service
The best way of handling Firebase in AngularJS surely has to be from within a service, so it's available to all Controllers across the App.
I just can't get it to work! ... I first tried using ...
0
votes
1answer
73 views
How to share data exclusively between a directive and a factory in AngularJS?
I want to build a modal directive with an Async API to open the modal.
What I was thinking about is a factory that returns me the API object that manipulates the modal directive. Using Angular-UI ...
0
votes
2answers
78 views
Loss of references between service and controller data in Angular.js
We encountered a problem when working with references between service and controller data
// We have a service that we use to store id and some other data
app.service('testService', function ($http, ...
1
vote
1answer
84 views
How to write services with $q and $http calls without being repetitive
I'm trying to figure out an elegant way to write AngularJS services without being so repetitive with the $q syntax.
Currently, I'm writing services like follows:
(function() {
function ...
2
votes
2answers
2k views
Uploading a file with AngularJS and bluimp on success callback of another form
I have followed the following tutorial in order to integrate the notorious bluimp jQuery file uploader in my AngularJS project.
After some research I found that in the options array, witihn the ...
183
votes
3answers
35k 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?