Having trouble accessing a custom service from a custom event. Every time the event is fired, the service reference turns out to be null.
@Component({
selector: "my-component",
template: mySource,
legacy: { transclude: true }
})
export class myComponent {
constructor(
@Inject("$scope") private $scope: ng.IScope,
private myService: MyService) {
$scope.$on('$routeChangeSuccess', function (event) {
this.myService.myFunction();
});
}
});
}
Encountering the following error when trying to reference myService:
Cannot read property 'myService' of null