Tagged Questions
1
vote
1answer
27 views
Best practice for dependency injection in an AngularJS service with TypeScript
I find dependency injection for AngularJS services in TypeScript to be somewhat cumbersome. Currently, I define a factory method inside my service class, and have to repeat all dependency injection ...
0
votes
3answers
23 views
How to initialize a service by calling a function from the service itself
I wrote a service. with a function inside it. Is it possible to initialize the service with that function? Have a look at this code.
app.factory('SidebarService',function(){
var self = this;
...
0
votes
1answer
53 views
New to AngularJS - basic customer management app
I'm still extremely new to AngularJS and am trying to make a fairly basic app to show a list of customers with one view, and a list of devices owned in another view.
What (I think) I'm struggling ...
0
votes
1answer
30 views
Watching model in a Service never catch any change
I have been struggling with this (supposed to be) simple issue for several hours.
What I have got is: there is a provider that will watch the model changes then will update the database accordingly. ...
3
votes
4answers
68 views
Purpose of AngularJS Services
I'm new to AngularJS. I'm currently looking at the services. Some of these services look like the replace functions already available in JavaScript. For instance, the $timeout service. Why does ...
0
votes
1answer
27 views
How to get result of service method in angular js?
I have this code :
PostApp.factory('loadPage', function ($http) {
return {
loadOtherPage: function (page, status, permition, order, cultureId) {
$http({
url: ...
0
votes
0answers
23 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
1answer
34 views
Angular - update controller data from another controller
I'm just starting to use AngularJS.
I have a simple CRUD app which communicates to REST api. I have two controllers which control my Projects data and Tasks data respectfully. On the backend Tasks ...
0
votes
1answer
24 views
Issues with returning an object from an angularjs promise
I am basically trying to retrieve the user's current position using the geolocation api and then pass the coordinates as parameters to an angularjs ajax call and return a custom "address" object as ...
0
votes
2answers
57 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
2answers
73 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
39 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
36 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
39 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
36 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
27 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
59 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
26 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
50 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
66 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
58 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 ...
6
votes
2answers
182 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
39 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
74 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
66 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
49 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
69 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
133 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
49 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
362 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
69 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
65 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
38 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
80 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
38 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
51 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
57 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
30 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
75 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
65 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
298 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
49 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
67 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
62 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
60 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
54 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
126 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
141 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
122 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 = "";
...