类型'typeof controller'上不存在属性

时间:2017-05-13 11:42:00

标签: angularjs typescript

我的代码如下所示:

App.Module.ts

/// <reference path="../../typings/app.d.ts" />
/// <reference path="../../typings/tsd.d.ts" />

module App {
    'use strict';
    ((): void => {

        var dependencies = ['app.core', 'ngRoute', 'toaster', 'ngAnimate', 'ui.bootstrap', 'angular-input-stars', 'angular-loading-bar', 'satellizer', 'ngFacebook', 'google-signin', 'angular-websql', 'angularPayments'];

        angular.module('app', dependencies)
            .controller('homeController', App.Controller.HomeController)
            .controller('listController', App.Controller.ListController)
            .controller('cartController', App.Controller.CartController)
            .controller('aboutController', App.Controller.AboutController)
            .controller('loginController', App.Controller.LoginController)
            .controller('orderController', App.Controller.OrderController)
            .controller('itemDetailController', App.Controller.ItemDetailController)
            .controller('loginPopupController', App.Controller.LoginPopupController)
            .directive("compareTo", Directive.CompareTo.factory)
            .config(App.RouteConfig)
            .config(['$authProvider', '$facebookProvider', 'GoogleSigninProvider',function ($authProvider, $facebookProvider, GoogleSigninProvider) {
                $authProvider.facebook({
                    clientId: '1879185642317770',
                    responseType: 'token'
                });
                $authProvider.google({
                    clientId: '812202105968-vn979ogd2rm99jqrlmgi96aq812balda.apps.googleusercontent.com'
                });
                $facebookProvider.setAppId('1879185642317770');
                GoogleSigninProvider.init({
                    client_id: '362273673781-8f7208bemoueppj8s85rc2ir28906psl.apps.googleusercontent.com',
                });

            }])
            .run(['$rootScope', '$window', '$route', '$http', function ($rootScope, $window, $route, $http) {
                (function () {
                    // If we've already installed the SDK, we're done
                    if (document.getElementById('facebook-jssdk')) { return; }

                    // Get the first script element, which we'll use to find the parent node
                    var firstScriptElement = document.getElementsByTagName('script')[0];

                    // Create a new script element and set its id
                    var facebookJS = document.createElement('script');
                    facebookJS.id = 'facebook-jssdk';

                    // Set the new script's source to the source of the Facebook JS SDK
                    facebookJS.src = '//connect.facebook.net/en_US/all.js';

                    // Insert the Facebook JS SDK into the DOM
                    firstScriptElement.parentNode.insertBefore(facebookJS, firstScriptElement);
                }());
                $window.Stripe.setPublishableKey('pk_test_G59B3E4vMrQKq1szNSp5lLqP');
                console.log(navigator.userAgent);
                if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
                    $rootScope.isMobile = true;
                }
                else {
                    $rootScope.isMobile = false;
                }

            }]);
    })();
}

OrderController.ts

/// <reference path="../../../typings/app.d.ts" />
/// <reference path="../../../typings/tsd.d.ts" />

module App.Controller {

    import Services = Core.Services;
    import Shared = Core.Shared;

    export class OrderCotroller extends BaseController {

        static $inject: Array<string> = ['baseAppService', 'userAuthorizationService', 'storageService', 'eventService',];

        constructor(
            appService: Services.BaseAppService
            , public userAuthorizationService: Services.UserAuthorizationService,
            public storageService: Services.StorageService,
            public eventService: Services.AppEventBusService) {

            super(appService);
        }

        logOut(): void {
            this.storageService.clearAll(false);
            this.eventService.broadcast(this.appService.appConstant.appEvants.onLogOut, "User logged out.");
        }

        goToHome() {
            this.appService.routerService.routeToPage('home');
        }
        routeTo(view) {
            this.appService.routerService.routeToPage(view);
        }
    }
}

现在,如果我运行上面的代码,它会给我以下错误:

\App.Module.ts(16,59): \u001b[39merror TS2339: Property \'OrderController\' does not exist on type \'typeof Controller\'.' }

我已经通过app.d.ts和tsd.d.ts包含了所有路径。但它仍然给我同样的错误。现在我在这里缺少什么来运行它而没有错误?

1 个答案:

答案 0 :(得分:2)

您的OrderController.ts中有拼写错误。它应该是export class OrderController extends ...