Reputation: 1
I'm working on two very similar projects (almost the same).
But the front end of the code is totally weak. I'm refactoring it and was thinking to use the most of the same code ( and specialize if there is a single rule for it ) for both applications and when generating the build on Grunt it generates the desired application...
I wonder if there is a more correct way to do this...
I would like to reuse as much JS and HTML as possible...
Upvotes: 0
Views: 236
Reputation: 2366
Angular JS is a framework, that perfectly divided the code into modules and make each module separate and reusable. Divide your code in modules. Each module having set of Controller, Service, Factory (REST API model), Directive (If any DOM Manipulation), Partials and CSS. Now you can use each Module separately. As in your case you have to use two different backends, make a rootScope property to determine which backend to use. According to the backend to be used configure your Base backend URL, Factories and Service and rest of directives, controllers, HTML and CSS remains the same.
Upvotes: 1