Not reusing existing object problem
In Angular 1.4.x when I'm trying to call smth like angular.module("myApp") twice, on second call I'm getting error of double initialization, but the right way is just to return previously created object.
Currently because of this behavior we needed to create variable in global context and reuse it; that's not helping to write clean code. If Angular know that module already initialized, so it must return reference to that object. And then instead of
var mainApp = angular.module("mainApp");
....
mainApp.controller(...)
we'll can use
//init
angular.module("mainApp");
....
angular.module("mainApp").controller(...)
And do it in as more places as we want. No more global variables and less code in bootstrappers. Some way can be done with controllers and other points of Angular.
Try to find something wrong in that approach.
Since this is a question about Angular 1.4 it should be logged in the angular 1.x project: https://github.com/angular/angular.js
Thanks. But I think this issue is a same for Angular 2. And maybe we'll not get this in Angular 1.x, but it must have for Angular2.
Do you have an Angular2 code sample where this would apply?
this isn't applicable in angular 2, and it's supported in angular1 already?
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.