Search code examples
javascriptangularjstypescriptangular-new-router

Property '$routeConfig' does not exist on type '($router: any) => void'


I am trying to use the angular new router in v1.4. I am using Typescript. When I try to compile, I get the following error.

Property '$routeConfig' does not exist on type '($router: any) => void'

This is my code

 /// <reference path="../Scripts/typings/angularjs/angular.d.ts"/>
/// <reference path="../Scripts/typings/angularjs/angular-route.d.ts"/>
module Application {
    "use strict";
    angular.module("app", ['ngNewRouter']);
    export var getModule: () => ng.IModule = () => {
        return angular.module("app");
    }

    getModule().controller('AppController', ['$router', AppController]);

    AppController.$routeConfig = [{
        path: '/',
        component: 'home'
    }, {
            path: '/detail/:id',
            component: 'detail'
        }, {
            path: '/login',
            component: 'login'
        }];

    function AppController($router) {

    }

}

Any help is appreciated. Thanks.


Solution

  • I made it work somehow. Following is the code. Now the new route compiles and works without any error.

    /// <reference path="../Scripts/typings/angularjs/angular.d.ts"/>
    /// <reference path="../Scripts/typings/angularjs/angular-route.d.ts"/>
    module Application {
        "use strict";
        angular.module("app", ['ngNewRouter']);
        export var getModule: () => ng.IModule = () => {
            return angular.module("app");
        }
    
        var AppController: any, $routeConfig: any;
    
        getModule().controller('AppController', ['$router', AppController = ($router) => {    }]);
    
        AppController.$routeConfig = [
            {
                path: '/',
                component: 'home'
            },
            {
                path: '/detail/:id',
                component: 'detail'
            },
            {
                path: '/login',
                component: 'login'
            }];
    }