Gajendra Jangid
What is the difference between Factory and Service?
By Gajendra Jangid in Angular on Mar 10 2018
  • Asif Khan
    Mar, 2018 15

    Use a .service() when you want to just create things that act as public APIs.Use it for things you would use a constructor for. Unfortunately if you don’t like using constructors in JavaScript, there isn’t much flexibility if you want to just use a simple API pattern.factory() A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a .service(), but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it.

    • 1
  • Asif Khan
    Mar, 2018 15

    Use a .service() when you want to just create things that act as public APIs.Use it for things you would use a constructor for. Unfortunately if you don’t like using constructors in JavaScript, there isn’t much flexibility if you want to just use a simple API pattern.factory() A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a .service(), but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it.

    • 1
  • Asif Khan
    Mar, 2018 15

    Use a .service() when you want to just create things that act as public APIs.Use it for things you would use a constructor for. Unfortunately if you don’t like using constructors in JavaScript, there isn’t much flexibility if you want to just use a simple API pattern.factory() A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a .service(), but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it.

    • 1
  • Asif Khan
    Mar, 2018 15

    Use a .service() when you want to just create things that act as public APIs.Use it for things you would use a constructor for. Unfortunately if you don’t like using constructors in JavaScript, there isn’t much flexibility if you want to just use a simple API pattern.factory() A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a .service(), but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it.

    • 1
  • Asif Khan
    Mar, 2018 15

    Use a .service() when you want to just create things that act as public APIs.Use it for things you would use a constructor for. Unfortunately if you don’t like using constructors in JavaScript, there isn’t much flexibility if you want to just use a simple API pattern.factory() A factory is not just “another way” for doing services, anyone that tells you that is wrong. It can however, give you the same capabilities of a .service(), but is much more powerful and flexible.A factory is not just a “way” of returning something, a factory is in fact a design pattern. Factories create Objects, that’s it.

    • 1


Most Popular Job Functions


MOST LIKED QUESTIONS