Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS: Dependency Management

We are currently planning a website which exists out of different AngularJS apps that will make use of common services. Services will be implemented in seperate files; to minimize the filesize of the apps we want to include/concatenate only those service-files that are used in the corresponding app - so we are looking for the best practise in dependency management.

is there something like requireJS in angular or what would you suggest to handle the includes? thanks in advance .)

like image 714
MrMuh Avatar asked Aug 25 '13 15:08

MrMuh


People also ask

What is dependency in AngularJS?

Dependency Injection in AngularJS can be defines as the software design pattern which defines the way the software components are dependent on each other. AngularJS provides a set of components that can be injected in the form of dependencies such as factory, value, constant, service, and provider. factory.

What is Dependency Injection and how does it work in AngularJS?

Dependency injection is a programming technique that makes a class independent of its dependencies. It achieves that by decoupling the usage of an object from its creation. This helps you to follow SOLID's dependency inversion and single responsibility principles.


2 Answers

I suggest to use the same organization as ng-boilerplate: https://github.com/joshdmiller/ng-boilerplate

I use an organization close to ng-boilerplat for one project and it allowed us to be modular in our dependency management.

like image 63
Julio Avatar answered Oct 04 '22 16:10

Julio


For me, the only build/deployment system that works like a charm for most web apps that have extremely js computation is yeoman.
This quote should describe what it is/does:

Yeoman 1.0 is more than just a tool. It's a workflow; a collection of tools and best practices working in harmony to make developing for the web even better.

So basically, it is a npm that installs all the boilerplate files, dependencies and configures your whole app with the help of generators. It uses bower and gruntalso takes care of the hard part of configuring grunt that is in charge of building/deploying your app.
I highly recommend yeoman as a modern and efficient workflow.

like image 24
gion_13 Avatar answered Oct 04 '22 17:10

gion_13