module.run() equivalent in Angular 2
See original GitHub issueI wonder if there’s something like angular.module().run()
in Angular 2. Angular 2 doesn’t have config()
and run()
anymore (which is good), but I think there are still some cases where we want to execute some code, once everything inside a component is compiled. Something that is only initially executed.
I’m currently playing with the instance of ComponentRef
that we get from bootstrap()
a la:
bootstrap(MyComponent).then((ref) => {
let app = ref.instance;
app.run();
});
Whereas run()
is a method that needs to be executed once everything inside MyComponent
is compiled. I also tried using onAllChangesDone
but it seems this is executed several times per second and not only once.
Issue Analytics
- State:
- Created 8 years ago
- Comments:10 (5 by maintainers)
Top Results From Across the Web
Equivalent of $compile in Angular 2 - typescript - Stack Overflow
Angular 4 came up with ComponentFactoryResolver which equivalent to $ compile in Angular 1.0 .See my answer stackoverflow.com/questions/34784778 ...
Read more >Upgrading from AngularJS to Angular
In a hybrid application you run both versions of Angular at the same time. That means that you need at least one module...
Read more >Use @NgModule to Manage Dependencies in your Angular 2 ...
The Angular 2 @NgModule decorator allows for easier management of dependencies within the Angular 2 framework.
Read more >From angular.module to ngModule - Telerik Blogs
The main organization mechanism is still the component within Angular 2 but ngModule was introduce to make organizing and connecting components ...
Read more >How to Migrate from Angular 1.x to Angular 2 in Simple Steps
After converting code for an AngularJS module to its equivalent Angular code, it might be needed that one of the converted component is...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
You can put work into the constructor of the module.
Use of
then
onComponentRef
should be the right approach.What specifically is not working?