Tagged Questions
4
votes
1answer
58 views
AngularJS - Deep object' property deletion
I know how to set object' "deep" property with $parse service , like in this post.
But how can i delete a deep property ? Not assign it to null with this:
...
0
votes
1answer
18 views
Combining resources in AngularJS
I have a RESTful API that provides me with employees and departments. In my AngularJS app, I need to know the employee and the departments the employee belongs to. I have defined two factory services ...
0
votes
2answers
23 views
How do I prevent angular-ui modal from closing?
I am using Angular UI $modal in my project
http://angular-ui.github.io/bootstrap/#/modal
I don't want user to close the modal by pressing on backdrop. I want a modal can only be closed by pressing ...
0
votes
1answer
33 views
AngularJS resourse structure for API
I have structure API:
api: {
users: {
details: {},
actions: {}
},
settings: {
users: {}
}
}
for example:
GET /api/users
return list of users
GET ...
0
votes
1answer
25 views
AngularJS $location.path(path) not updating at first
I have a piece of code where I call $location.path(name) and nothing seems to happens (at first). I can call console.log($location.path()) and it does show the new path -- but the view doesn't change.
...
0
votes
2answers
28 views
AngularJS Execute function after a Service request ends
I am using AngularJS Services in my application to retrieve data from the backend, and I would like to make a loading mask, so the loading mask will start just before sending the request. but how can ...
0
votes
1answer
32 views
How to mock $window.location.replace in AngularJS unit test?
I've got the following service:
angular.module("services")
.factory("whatever", function($window) {
return {
redirect: function() {
$window.location.replace("http://www.whatever.com");
...
1
vote
0answers
39 views
In Angular JS, can we use ng-controller twice? [on hold]
I' am trying to develop an web application using Angular JS. I' am trying to create two Angular JS controllers in the same page but things seems to be not working. Please can someone tell me where I ...
1
vote
1answer
21 views
How to unit-test the interaction of an Angular Service with $cookies?
I currently have a service that is depending on a variable set in $cookies. However, when I want to unit test the interaction between the service and the value stored in $cookies, then the service is ...
0
votes
0answers
36 views
How to get JSON object (as 'GET') from url using $resource in angularjs
I'm an beginner in angularjs and don't have any idea about web services either. My requirement is something like this:
I have to get a JSON object from my url ...
0
votes
1answer
64 views
AngularJS, service which merges 2 resources
I am working with AngularJS framework (noobie), and I am trying to develop a service String which has to merge 2 resources. I mean merge the result (json) of 2 requests:
string/:stringId.json
...
0
votes
2answers
44 views
Angularjs, setting the value of a value service at runtime [closed]
I am new to Angularjs. I am working on my personal website and am using angular. I want people to be able to login. After logging in I want to store there username in a valueservice so that it is ...
0
votes
2answers
54 views
angular service and http request
creating service
myApp.factory('serviceHttp', ['$http', function(http) {
http.get($scope.url).then(function(result){
serviceVariable = result;
}
return serviceVariable;
}
Controller
...
1
vote
2answers
78 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
27 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
70 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
33 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
76 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
36 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
27 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
35 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
35 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
71 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
92 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
41 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
41 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
44 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
37 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
64 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
51 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
53 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
85 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
62 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
195 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
41 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
106 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
92 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
53 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
79 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
156 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
59 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
551 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
80 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
80 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
42 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
99 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
49 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
57 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, ...