angularjs – 未调用Angular Typescript Controller构造函数

前端之家收集整理的这篇文章主要介绍了angularjs – 未调用Angular Typescript Controller构造函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在使用Angular类型脚本.

我在类型脚本中有模型类

module app.form {

    export class Patient{

        constructor(
            public firstName: string,public lastName: string,public gender: string,public birthDate: Date,public currentMedications: string,public notes: string,public isMedicare: boolean,public medicareName: string,public medications: string[],public ethnicity: string[],public billingInfo: BillingInformation,public specimenInfo: SpecimenInformation,public assayRequested: AssayRequested,public authorizationDetail: AuthorizationDetail
        ) {

        }
    }
}

使用类型脚本的我的Controller代码是这样的

module app.form {
    export class MainController {
        constructor(public patient: Patient) {

        } 
    }   
}

我的app文件看起来像这样.

module app.form {
    angular
        .module("formApp",[
            "ngMaterial","ngMdIcons","ngMessages"
        ])
        .controller("MainController",MainController);
}

我按此顺序在html文件注册所有脚本

<script src="Scripts/angular.min.js"></script>
    <script src="Scripts/angular-resource.min.js"></script>
    <script src="Scripts/angular-animate/angular-animate.min.js"></script>
    <script src="Scripts/angular-aria/angular-aria.min.js"></script>
    <script src="Scripts/angular-messages.min.js"></script>
    <script src="Scripts/angular-material/angular-material.min.js"></script>
    <script src="Scripts/angular-material-icons/angular-material-icons.min.js"></script>

    <script src="app/model.js"></script>
    <script src="app/controllers/main-controller.js"></script>
    <script src="app/app.js"></script>

当我运行我的应用程序时,我看到这个错误

enter image description here

我在哪里做错了?

解决方法

解决错误,必须在使用typescript时在控制器中使用静态$inject

static $inject = [];

猜你在找的Angularjs相关文章