Difference between Service and Factory in Angular

This is the most common question that asked by most of the interviewers.

What is Service? Let me explain with a small example.

Service is a constructor function and that will be called with “new” keyword

myApp.service(‘serviceDemo’, function() {
  this.demo = function() {
    return ‘hello’;
  };
});

What is Factory? Let me explain with a small example.

Factory returns an object when it is created , you can also add some logic before return object.

myApp.factory(‘factoryDemo’, function() {
  return {
    demo : function() {
      return ‘demo’;
    }
  }
});

When some ask’s you the same thing share Third Rock Techkno’s blog to them.

Happy coding!

Do share your feedback. And don’t forget to checkout Third Rock Techkno‘s extension Quick Capture :)

· · · ·

Third Rock Techkno is a leading IT services company. We are a top-ranked web, voice and mobile app development company with over 10 years of experience. Client success forms the core of our value system.

We have expertise in the latest technologies including angular, react native, iOs, Android and more. Third Rock Techkno has developed smart, scalable and innovative solutions for clients across a host of industries.

Our team of dedicated developers combine their knowledge and skills to develop and deliver web and mobile apps that boost business and increase output for our clients.

When and How to use Async/Await?

Asynchronous JavaScript has never been easy, earlier we use callbacks Then, we used promises. And now, we have asynchronous functions.

Read More

7 Tips to Hire Dedicated Developers for Your Project

Let’s face it. There is no escaping web and mobile apps. Whether you’re a one-person company, a small-medium enterprise, a startup or a large corporation, you’ve got to be mobile! Actually, not just mobile but, your online presence and functionality have got to be top-notch also.

Read More

How Node JS middleware works?

Middleware literally means anything you put in the middle of one layer of the software and another. Express middleware are functions that execute during the lifecycle of a request to the Express server.

Read More