sonicoder86 / angular2-babel-esnext-starter

Angular development and testing examples with Babel in Javascript (ES6/ES7).

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using router-link to navigate to another component does not invoke the onInit method

janbaer opened this issue · comments

I just use portions of you ES6 angular2-starter package and I've the exactly problem that is described in this issue in the angular 2 project.

angular/angular#4809

Have you ever had this problem? In the most answers I found in this thread they are using the angular2-polyfills, but you're not, why not?

Could you maybe please take a look on my project setup, if you can see any obvious problem? This would be very helpful for me! Thanks!

https://github.com/howcani-project/howcani

Haven't experienced it yet but will look into it.
There is no specific reason for not using the polyfills, will include and try also with it.

I also tested it with your project, but I couldn't reproduce it. It worked, even if you're loading the polyfills and angular modules in the same order. When you want to reproduce it then you just need to clone the project, call npm install and then gulp serve. And then you can see that on the place where the router-outlet is, nothing will be loaded. But when you click on the HowCanI logo then the route will be executed for the second time and then ngOnInit will be called and you can see the items. The project is also online here http://www.howcani.eu

So it is working with the starter but now within your project?

Yes, your starter project is working, but not my project. But I'm using the same configuration with loading the polyfills from shim.js and then the angular2 modules. And I'm wondering why you don't have the problem, but I have it...

And by the way, the problem is not occurring in the current Safari version, but in Chrome on MacOS.

This problem was solved by the help of @brandonroberts. It's was an external library that I use and that should be imported before the zone.js library.

angular/angular#8012 (comment)

Seems like one crazy bug

Indeed, amazing. I've put zone.js at the end, problem solved