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 ...
0
votes
1answer
14 views
Global $http.get() that updates every 5 seconds across all scopes/controllers in Angular 1.5
In my Angular project I am loading json list from my api that is constantly updating. I would like to have this update every 5 seconds across all my angular controllers without making a new request ...
1
vote
1answer
20 views
Why use Angular Service to gather information, instead of just $http?
Two options, which is better and why:
Example A.
app module
service containing model data
controller to call in data from service
File 1: Users.js:
angular.module('users', []);
File 2: ...
1
vote
2answers
16 views
issue with reciving data from WebApi in AngularJs Service
I'm gonna use AngularJS Service in my applications and make everything clean and nice.. I followed some articles for this purpose. but its seems not completed. Right ??
I don't see any error or ...
0
votes
1answer
18 views
why doesn't $http work when Authorization header set?
New to Angular - cant figure this one out. $http call doesn't reach the server when Authorization header is set. My function:
loginHttp: function(name, pw) {
var req = {
method: ...
0
votes
3answers
27 views
angularjs: injecting async service into directive with $resource
I'm very much trying to get my head around angularJS and directives still.
I have an existing REST service that outputs JSON data as follows (formatted for readability):
{"ApplicationType":
...
0
votes
0answers
29 views
dynamic factory angularjs (resolve data to controller)
I read an answer about "dynamic factory" from How to create Dynamic factory in Angular js?
It works great but some additional conditions required for my project make me tired.
conditions are simple.
...
1
vote
6answers
49 views
AngularJs: pass $scope variable with service
I have two controllers and in one of them I declared a $scope variable that I would like visible in the second controller.
First controller
app.controller('Ctrl1', function ($scope) {
...
-1
votes
0answers
13 views
i want to show loading icon if it gets hit to server for specific partial views each
I want to show loading icon inside of two partial pages if they get hit to server.
currently i am using progress bar on top of the page, but i want to use loading icon for both the partial views if ...
1
vote
3answers
55 views
AngularJS $scope inheritance service
I'm having some trouble with my code. I can't pass nor console.log the inherited $scope.user in my data service. As I'm having this problem also in another situation which looks the same I guess it's ...
0
votes
1answer
35 views
angularjs get the error message from the service to the controller
Factory that gets the rates using REST
.factory('rateResource', ['$resource', function ($resource) {
return $resource('/rates/:currency/:effectiveDate', {
currency: '@currency',
...
0
votes
0answers
20 views
How to delay catch function in angularjs during routing to a page?
I'm using $rootscope and two other service inside a service to update the data based on the current car. CarsService helps with car selection and DataSelection point to the folder that keeps the data. ...
0
votes
1answer
23 views
How to add a particular funtion from service to directive in angularjs
This is a funtion i have added in localcacheService.
I want to add this function in directive.
LocalCacheServiceClear.prototype.isAvailable = function() {
this.cache.clear();
}
My directive ...
0
votes
1answer
19 views
Angular Service Undefined
In the code snippet below, I'm getting "ReferenceError: 'ShoppingListService' is undefined". I can't see what the error might be, been banging my head against it and searched for a while now, anyone ...
1
vote
4answers
44 views
Angularjs - Inject factory without reference
I have the following code:
main.js
angular.controller('myCtrl', function($scope, $rootScope) {
$scope.name = "Bob";
}
myservices.js
angular.factory('myService', function($http) {
var ...
1
vote
1answer
28 views
Angular js service value does not updates in the view
I'm using the stateProvider, and when the state is changed i want to update my breadcrumbs in the header. Instead of writing for each state its own embedded view, i just put on the service that shares ...
1
vote
3answers
46 views
How to keep track of current user in angularJS controllers?
factory / service:
angular.module('phoenix-template')
.factory('User', ['$http', function($http){
function current(){
...
0
votes
1answer
18 views
Sending received Rest data in service file to controller angularjs
I am new to angular js and I have a problem sending the received data from my service file to controller, which ultimately binds to my html. Can someone please help me resolve this problem. Thank you.
...
2
votes
1answer
30 views
Nested ng-repeat to repeat on parent repeats ID
I am trying to perform a nest ng-repeat (using ng-repeat-start and ng-repeat-end).
The first repeat displays a list of locations as well as an associated id. For example:
Mauritius | ID: po8j3mau72
...
1
vote
1answer
37 views
xmlhttprequest cannot load response URL. for preflight has invalid http status code 405 for $http.delete
I have web API service:
public void Delete(int id)
{
}
Web api-Web.config
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" ...
0
votes
1answer
23 views
Factory doesnt return http data response
Im trying to get http post data response using the code below (it is working).
app.factory('LoginService', function($http, $location) {
return {
existUser: function(loginObj)
{
...
0
votes
1answer
56 views
Calling multiple REST APIs using response of first API in AngularJS
I am new to AngularJS and trying to make an application which loads data by calling APIs. It is like I am fetching the list of boxes of type A (Resource Groups) and then each Box of type A has ...
0
votes
2answers
44 views
How to access variables in angularjs $http service
I have my controller and it fetches data from 2 json files using $http service.
This data is stored inside $scope variables like $scope.name and $scope.application.
But I am unable to parse over both ...
0
votes
1answer
41 views
How can I pass an data from factory to my controller in angularjs?
I'm trying to move all the business logic from my controller to the factory, but I'm having some trouble passing fields data.
factory.js
app.factory("Quote", function ($resource) {
// TODO: this ...
0
votes
2answers
26 views
Angular service passing data to controller
I am trying to create a service that passes data to controller.
I cannot see any errors in the console but yet the data won't show. What exactly am I doing wrong?
Service
...
-1
votes
3answers
50 views
AngularJS Services injecting each other causing infinite loop [duplicate]
I'm currently facing a nightmare in my application. I have 1 Service and 1 Factory and they need to access each other, like so:
// Dependency Injection
MyFactory(MyService)
MyService(MyFactory)
...
0
votes
2answers
67 views
CastError: Cast to ObjectId failed for value “users.client.module.js” at path “_id”
This is again another error I'm getting following through a MEAN stack development book. We've just added a new users module and a users service for allowing angular to use user information from an ...
0
votes
1answer
23 views
angular event listener
I'm working on a huge project for a client, so to make the code cleaner, i'm doing some rework. I'm having this part of code :
var removeListener = $rootScope.$on('logoutEvent', function () {
...
0
votes
1answer
33 views
How to declare and use modules, controllers, services and bootstrap manually in Angular?
i'm trying to build an AngularJS app that has one Controller, one Service and that Bootstraps manually (no ng-app). The problem is that I keep having an error :
Argument 'AppController' is not a ...
0
votes
1answer
31 views
directive unable to retrieve data from a service
I have a little SPA using angular. The concept is simple, after login, $routeProvider redirects to a home page where I have a homeController specified.
this is from my home view that is rendered by ...
-1
votes
1answer
16 views
How to pass json varaible in controller AngularJS
I am new to angularJS. I have some doubts.
I have a json data value in one variable.
How to use that varaible in controller ?
Example
$scope.pareseJson($scope.productresult);
In productresult I ...
0
votes
1answer
25 views
Angularjs controller fails to load http data from cachefactory service
Newbie to angular, using service I'm trying to load cachefactory and using the cache from controller.
Here is service methods
codesApp.service('CodeFilterService',function($filter, $http, ...
0
votes
1answer
50 views
Typescript: Inject custom service in controller in
I'm trying to create a custom service and $inject it into my controller. It seems to be a fairly basic problem, but I havn't been able to find a working solution.
HTML:
<!DOCTYPE html>
...
0
votes
1answer
38 views
Angularjs “type” file is empty
I'm trying to upload a file but the "type" it appears empty.
I am following this tutorial: http://www.tutorialspoint.com/angularjs/angularjs_upload_file.htm
# Input file for upload
<input ...
0
votes
1answer
43 views
Accessing directive scope in controller using service
I was trying to access a value returned by a directive in my controller. I tried with a service. It's not working; it seems like the updated directive's return value is not picked up by the ...
0
votes
3answers
44 views
Returning a promise in a factory
Hoe can I return a promise in a factory to use in my controller given the example below:
Factory:
angular
.module('security.authorisation')
.factory('AuthService', [
'$http',
...
1
vote
2answers
33 views
When and where to use multiple controllers/directives/services/factories in angularjs?
I am very new to angularJs.I understood the some concepts but still a lot of things are not clear.I am looking for your help to understand me the following scenarios with some demonstration for clear ...
1
vote
1answer
59 views
Angular JS: update controller when data change in second controller
what i m doing:
simple html file shows first page , in this page i have one title and button, initially i set $scope.index = 0. so, we set first position of array. when we click on next button it ...
0
votes
1answer
25 views
Update value in controller when factory changes
I have a factory service to control a shopping cart and I'm will problems to sync the data with controller when I'm still configurating the shopping cart.
the process consists of analyzing whether or ...
0
votes
2answers
34 views
Bug - AngularJS Service with GET JSON file
I am working on a simple sample AngularJS application that reads data from an external JSON data file. I have tried everything, and I cannot find why the application does not work. Any input would be ...
1
vote
2answers
18 views
First Angular JS App - issue loading service
I do hate asking new questions and in fact this is my first I believe, but you can take my word for it that I have tried my utmost to find an answer without leaning on you guys.
It's very straight ...
1
vote
1answer
22 views
ngMap directive not displaying the location coordinates taken from service file
I am trying to call location coordinates from service file and display in google map view. But for some reason the data binding is not working, and there are no errors and the controller is calling ...
0
votes
0answers
31 views
Angular factory gets iterated dozens of times
In my Angular app I have a factory called AuthFactory.
So far I am injecting this AuthFactory in one .run block within my application, and four separate controllers - three of which are controllers ...
0
votes
2answers
38 views
AngularJS: Pass textbox value to services
I am new in angularJS. Currently working on services. I tried to pass text-box value to services. I don't know how to pass. I code but it's not working.
app.service("wishService", function ($timeout) ...
0
votes
0answers
26 views
calling a webservice from angularjs from a sample which works in rest client
I am trying to call a webservice from angularjs.
The webservice is working fine from Chrome Rest client but i am getting error from Angularjs which is inside an ionic application.
I am calling service ...
0
votes
2answers
32 views
Service function not found in angular app
I added a service to my angular controller, but it says every time there is no function. I really dont know why and hope there is someone who can help me.
Here is my userCtrl.js ...
1
vote
1answer
35 views
Angular - reusing code (service or controller)
I'm using Angular to develop commenting functionality for a web app.
Currently there are two sections in the application were a user can comment:
Category
Product
About 90% of the commenting ...
0
votes
2answers
24 views
Angular template not displaying the service file data
The template file is not displaying the data from the service file, can someone please check the code and correct me. Thank you.
Also I checked if data is passed by controller, which is happening. ...
0
votes
2answers
36 views
No-JavaScript or no-cookies-enabled browser
Assume that a user has JavaScript or cookies turned off in the mobile/desktop browser. Now, when a user comes to the site, the user should be re-directed to a specific page (e.g. some error page). How ...
1
vote
2answers
45 views
how to convert $resource to $http?
How can my use of $resource be converted to instead leverage the raw $http service? And what exactly does $resource do that $http does not?
return $resource(API_LINK+'/api/users/', {
id: '@_id'
...
0
votes
1answer
27 views
Injecting modules into service AngularJS ES6
I'm new to ES6 syntax of within Angular. I'm trying to create a service and use $http and LocalStorageModule
When I try to inject the two modules into my service I get errors about my syntax not ...