无法加载模板:uib/template/modal/window.html

Mar*_*sen 8 javascript angularjs angular-ui-bootstrap

我觉得我已经尝试了一切,我仍然得到错误:

无法加载模板:uib/template/modal/window.html

在我的索引文件中,我添加了以下内容:

<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>
<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script>
Run Code Online (Sandbox Code Playgroud)

在我的app文件中添加:

    'ui.bootstrap', 
Run Code Online (Sandbox Code Playgroud)

在我的控制器文件中,我添加了以下内容:

$uibModal
Run Code Online (Sandbox Code Playgroud)

this.openPayment = function () {
    var modalInstance = $uibModal.open({
        ariaLabelledBy: 'modal-title',
        ariaDescribedBy: 'modal-body',
        templateUrl: 'payment.html',
        controller: 'paymentController',
        controllerAs: '$ctrl',
        size: 'lg',
    });
}
Run Code Online (Sandbox Code Playgroud)

在我的paymentControlleri中添加了以下内容:

angular.module('Payment').controller('paymentController', function ($uibModalInstance) {
    var ctrl = this;
});
Run Code Online (Sandbox Code Playgroud)

而且payment.html:

    <div class="modal-header">
    <h3 class="modal-title" translate="ACADEMY.EDIT.COURSES.CREATE"></h3>
</div>
<div class="modal-body">
</div>
<div class="lb-modal-footer">
    <a class="btn btn-grey" tooltip="{{ 'TOOLTIP.CANCEL' | translate }}" ng-click="CTRL.cancel()"><i
            class="fa fa-ban"></i></a>
    <button class="btn btn-success m-l-xs {{CTRL.academyCourse.course ? '':'disabled'}}" tooltip="{{ 'TOOLTIP.SAVE_AND_EXIT' | translate }}" ng-click="CTRL.addCourse()"><i
            class="fa fa-check-square-o"></i></button>
</div>
Run Code Online (Sandbox Code Playgroud)

所以有人能告诉我我做错了什么吗?

sva*_*rog 24

  1. 确保您已经附加了ui-bootstrap的模板版本或没有的模板版本.

    <!-- remove this -->
    <!--<script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>--> 
    <script src="node_modules/angular-ui-bootstrap/dist/ui-bootstrap-tpls.js"></script>
    
    Run Code Online (Sandbox Code Playgroud)

在你的情况下,你错过了模态模板(uib/template/modal/window.html),所以我会保留ui-bootstrap-tpls.js.

  1. 确保您正确链接到脚本,转到页面源并尝试访问uib脚本.您可能已构建项目但脚本文件未添加到构建中.

  2. 确保添加角度脚本以及 index.html中添加引导程序文件添加uib脚本