Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Feature Request: Delete / Redefine Module #14743

Closed
aderito7 opened this issue Jun 9, 2016 · 1 comment
Closed

Feature Request: Delete / Redefine Module #14743

aderito7 opened this issue Jun 9, 2016 · 1 comment

Comments

@aderito7
Copy link

aderito7 commented Jun 9, 2016

I am making this feature request keeping in mind that #8977 and #3881 have been closed (but not resolved) as the OP deemed their feature request not necessary anymore, but I've found use case for it. Please bear with me and I would really like to contribute to the repo and make this functionality available if I can get help figuring out where to start looking; there's clearly expression over the web of people liking something like this.

With the following I would like to be able to define a module the first time and then change it on the fly later on. The reason is that my modules are dynamically generated and I'd rather reload one module than the whole app once One JavaScript file changes; it is Huge and Slow to load. The JS files are watched for changes and loaded lazily but always the initial module persists, i.e. 'This will be logged the first time' always gets logged even though the new JavaScript executes it does not overwrite the old module.

I think this would be a great tool for the AngularJS community but I don't know as yet it if it's already possible (I keep reading it's not). Alternatively I'd be happy if I could achieve the same using controllers/directives/1.5components

// First state of angular module
angular.module('myApp.view1', [])
.controller('View1Ctrl', ['$scope',function($scope) {
  $scope.buttonClick = function () {
    console.log('This will be logged first time');
  }
}]);


// Second state of angular module
angular.module('myApp.view1', [])
.controller('View1Ctrl', ['$scope',function($scope) {
  $scope.buttonClick = function () {
    console.log('This will be logged the second time');
  }
}]);
<button ng-click="buttonClick()">Button</button>

Here is a further working example if anything is still not clear http://jsbin.com/xirixusuyu

@gkalpak
Copy link
Member

gkalpak commented Jun 9, 2016

Replacing modules is a pretty slippery slope. You can easily end up into an inconcistent state, where some of your different services/controllers/directives/views are using different versions of their dependencies.

We are considering adding support for lazily loading modules though. This is tracked in #11015.
There are also 3rd party modules that are offering this functionality already.

I'm closing this as a duplicate of #11015. Let's continue the discussion there.

@gkalpak gkalpak closed this as completed Jun 9, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants