模态控制器未得到解决

时间:2015-05-19 10:54:21

标签: javascript angularjs twitter-bootstrap angularjs-directive typescript

我正在尝试使用angular / angular-ui-bootstrap打开一个模态窗口,它对视图非常有效,但是相应的控制器似乎没有得到解决,而角度也没有吐出任何错误。这可能有什么问题?

// calling controller
export class TestController {

    private _modal : angular.ui.bootstrap.IModalService;

    constructor($modal : angular.ui.bootstrap.IModalService) {
        this._modal = $modal;
    }

    edit(myEntity : IEntity) {

        this._modal.open({
            templateUrl: "app/modules/stuff/entity.detail.modal.html",
            controller: "App.Stuff.EntityDetailModalController as modal",
            resolve: {
                item: () => myEntity
            }
        });

    }

}

// modal controller
export class EntityDetailModalController {
    constructor($modalInstance: angular.ui.bootstrap.IModalServiceInstance, item) {
        // ...
    }
}

// controller registration
stuffModule.controller("App.Stuff.EntityDetailModalController", ["$modalInstance", "item", EntityDetailModalController]);

1 个答案:

答案 0 :(得分:0)

控制器名称应指定为“AS”,您可以单独指定控制器别名:

this._modal.open({
            templateUrl: "app/modules/stuff/entity.detail.modal.html",
            controller: "App.Stuff.EntityDetailModalController",
            controllerAs: "modal",
            resolve: {
                item: () => myEntity
            }
        });