0

I defined a local ref to routeParams service in my controller. routeParams:IRouteParamsService Webstorm even code completed this for me and generated an import statement at the top of my controller:

import IRouteParamsService = angular.route.IRouteParamsService;

However, this produces a typescript error,

Module 'Angular' has no exported property 'route'

I tried removing it, I tried adding angular-ui-router.d.ts to my TSD typings collection. Maybe I'm missing a different TSD definition file?

Here's the rest of the useful parts of my injector/constructor.

import ILocationProvider = angular.ILocationProvider;
import IRouteParamsService = angular.route.IRouteParamsService;
import IScope = angular.IScope;

interface ILoginControllerScope extends IScope {
  userObject:any;
  //...
}

class LoginController {

  formType = 'login';
  userModel:UserModel;
  location:ILocationProvider;
  routeParams: IRouteParamsService;
  scope:ILoginControllerScope;

  static $inject = ['$scope', '$location', 'userModel', '$routeParams'];
  constructor($scope, $location, $userModel, routeParams ){

    this.scope = $scope;
    this.location = $location;
    this.userModel = $userModel;
    this.routeParams = routeParams;
    //...
FlavorScape
  • 13,301
  • 12
  • 75
  • 117
  • Do you use the in-build router (a.k.a $routeProvider) or ui-router (a.k.a. $stateProvider). In the first case you need angular-route.d.ts and in the second case angular-ui-router.d.ts. If it still fails, mabye the compiler doesn't pick up this definition file? – FlorianTopf Dec 04 '15 at 23:33
  • oh, duh. i totally used the mis-matched tsd. – FlavorScape Dec 08 '15 at 19:27

0 Answers0