angularjsangular-new-router

How can we watch expressions inside a controller in angular 1.4 using angular-new-router


Since we cannot inject $scope inside controllers in Angular 1.4+, how can we watch expressions the way we used to do with $scope.$watch?

An attempt to inject $scope can be seen here ("Could not instantiate controller" error), and tutorials tells us that:

Angular wont be able to instantiate the controller if we pass $scope in it. It defines its observable properties on this. (source)


Solution

  • I ran into this and needed an npm package; no good having everyone on the team build from source for the time being. We released an interim package on npm that fixes this issue: npm install loomio-angular-router@0.5.7

    Note: you may need to rename ng-viewport to ng-outlet to get the interim package working.