Linked Questions

2 votes
1 answer
932 views

Should I use factory or service for fetching data in AngularJS? [duplicate]

I'm learning AngluarJS and I have a very simple project set up. I have a file called ApiService.js which is used to pull data from a RESTful server somewhere. At the moment it looks like this: var ...
Cameron Ball's user avatar
  • 4,138
0 votes
0 answers
74 views

When should I use factory or service in angular? [duplicate]

I am new to Angular services/factory. This is my simple angular service & factory. Both outputs the same. //defining service app.service('myService', function () { this.name = ''; this.setName = ...
aarti's user avatar
  • 104
3426 votes
30 answers
786k views

AngularJS: Service vs provider vs factory

What are the differences between a Service, Provider and Factory in AngularJS?
Lior's user avatar
  • 40.6k
1082 votes
9 answers
348k views

angular.service vs angular.factory

I have seen both angular.factory() and angular.service() used to declare services; however, I cannot find angular.service anywhere in official documentation. What is the difference between the two ...
Jakob Jingleheimer's user avatar
224 votes
4 answers
256k views

AngularJS : Factory and Service? [duplicate]

EDIT Jan 2016: Since this still gets attention. Since asking this I've completed a few AngularJS projects, and for those I mostly used factory, built up an object and returned the object at the end. ...
Cameron Ball's user avatar
  • 4,138
40 votes
2 answers
39k views

Creating common controller functions

How do I create some sort of utils bundle that would be accessible from all my controllers? I have this route code in my main module: 'use strict'; angular.module('lpConnect', []). config(['$...
Shlomi Schwartz's user avatar
23 votes
2 answers
30k views

AngularJS and WebSockets beyond

I just read this post, and I do understand what the difference is. But still in my head I have the question. Can/Should I use it in the same App/Website? Say I want the AngularJs to fetch content and ...
Diogo Barroso's user avatar
1 vote
2 answers
4k views

AngularJS : Service variable changes not applying

Im currently having an issue where when I call a function in a service that changes its own internal variable it doesn't appear to stay unless I change it from a controller. When I output the variable ...
strspl's user avatar
  • 63
0 votes
1 answer
3k views

Changing $scope variable value in controller not changing value on view

I am working on Cordova tool and angularjs for my application. cordovaApp.controller("VacationCtrl", function ($scope, $http, $location) { $scope.tempdate = "2222"; $scope.ruleDetails ...
Keval Patel's user avatar
0 votes
3 answers
627 views

Angularjs - Cross Controller Calculation

I am trying to create an application with Angularjs, It's a fairly large application which needs to be broken down into multiple Controllers. I need to calculate across controllers. angular....
Jay's user avatar
  • 71
0 votes
2 answers
492 views

Transfer some data from one controller to another, or how to change controller to service

How can i take information from one controller to another, or how can i make service from a controller? I need to take coordinates and save it to object with some other variables, if i put dependencie ...
Mark's user avatar
  • 209
1 vote
3 answers
334 views

use angular factory to hold a value for rest of application to access to minimize server calls

I have the following factory: angularModule .factory('ArticleCategoryService', function ($http, $q) { // Service logic // ... var categories = []; var _getCategories = $http.get('/...
PGT's user avatar
  • 2,077
0 votes
1 answer
109 views

AngularJS - Why use a service?

I have been using AngularJS on a new project and I really like it. So much so I think I will do all my future web projects with it. I have done lots of reading on the different types of Provider there ...
Ben Guest's user avatar
  • 1,588
-3 votes
1 answer
62 views

Create a custom http service that will request external JSON file. pure angularjs only

I have a http service which will call external json files and load it into a grid. My problem is i need to create a custom http service so that i could use the same in different controllers. The ...
Prag's user avatar
  • 1