UI Router Resolve and TypeScript

I am wondering how I will use UI Router resolution using TypeScript.

.state("signin.notActivated", <ng.ui.IState> { controller: "SigninCtrl", controllerAs: "signin", url: "/notActivated", resolve: { inProgress: function() { return { formData : null } } } }) 

In my controller I entered my solution.

 constructor(public $state : angular.ui.IState, private inProgress) { this.init(); } private init = () => { this.someData = this.inProgress.formData; // error } 

I get an unknown provider error because TypeScript is trying to register it as a service.

enter image description here

Can this be done?

+6
source share
2 answers

Try entering it as follows:

 static $inject = ['$state', 'inProgress']; constructor(public $state : angular.ui.IState, private inProgress) { this.init(); } 
+1
source

Make sure that you only call the controller through the router. Calling the controller directly from the html directive via ng-controller ( ng-controller="SigninCtrl as signin" in your case) will not be nested inProgress, and therefore you will get into this error.

0
source

All Articles