What is the difference between .service() and .factory() in Angular JS?

.service() is a just method on our business layer of the Angular application and use ‘this’ keyword.

app.service('userService', function(firstName) {

var firstName = firstName;
this.getFirstName = function() {
return firstName;
};
});

.factory() is also method it can be use ‘return’ keyword.

app.factory('userFactory', function(firstName) {
  var firstName = firstName;
return {
user : firstName
}
});
Like what you read? Give David Lee a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.