Closed BobDankert closed 5 years ago
Also posted to ngMigration-Assistant repo, here: https://github.com/ellamaolson/ngMigration-Assistant/issues/5
Hi @BobDankert, thank you for bringing this up. If you find specific bugs with ngMigration Assistant, please file them in that repo. If you have a general issue or question surrounding migration, please file them here.
Perfect. I'll close the issue on ngMigration-Assistant and keep this one open. It was a bit confusing in the Angular blog to know which repo gets the questions :)
@BobDankert you can subscribe to router events and take action accordingly:
this.router.events.pipe(
filter(event => event instanceof NavigationEnd),
map(event => event.url),
filter(url => url.startsWith('....')),
).subscribe(() => do stuff);
@jpzwarte Thanks - I meant in AngularJS? The ngMigration assistant tool is saying to eliminate $rootScope prior to using ngUpgrade, but I'm not sure how to get rid of $rootScope prior to using ngUpgrade.
I sometimes still use $rootScope
in my angular.js code. I wouldn't immediately focus on that. I don't think getting rid of $rootScope
is necessary in order to use ngUpgrade.
Getting rid of $rootScope isn't necessary - I'm currently using it quite a lot in a hybrid application.
As far as I'm aware, they're making that recommendation because there isn't an equivalent to $rootScope in Angular, so you'll have to do some rewriting when you convert from 1.x to the current version.
Yes, @joshorvis is correct - the reason we are scanning for $rootScope is that it will require manual restructuring of your code in order to move to Angular. However, it can exist as part of a hybrid application, so we will make a change to the recommendation to reflect this.
First off - thanks for the efforts with this forum! I used the ngMigration-Assistant tool to analyze our project, and was recommended to go the path of ngUpgrade along with some tasks we are currently undergoing. It confirmed the path/approach we've been working on for our large angular applications. One of the items listed is to remove $rootScope from our application. For the most part we have done this, but we still use this in a couple services to execute some checks when the route changes by using $rootScope.$on('$routeChangeSuccess'. What would be the recommended way to move away from $rootScope but still be able to have a service execute code when a route changes?
We also have the same issue in that we also use $locationChangeSuccess to update some variables in Google Analytics (perhaps there is a better way to do this now, but it was the recommended approach at the time we wrote it).
Any thoughts/advice on how to handle this would be appreciated.
(I also posted this on the ngMigration-Assistant repo, as it's not clear to me which repo questions should be directed to)