AngularJS 为 templateURL 使用部分时不显示模态

AngularJS modal not displayed when using partial for templateURL

我在使用 ng-include 标记加载到我的主视图中的部分文件中有一个模式,但找不到模板。我没有在控制台或控制台网络选项卡中看到正在加载的模板。我收到以下消息:错误:[$compile:tpload] 加载模板失败:rxsignalUpdateModal.html

控制器:

$scope.open = function (size) {

    var modalInstance = $modal.open({
        animation: $scope.animationsEnabled,
        templateUrl: 'rxsignalUpdateModal.html',
        controller: 'ModalInstanceCtrl',
        size: size
    });
};

查看:

<div class="col-md-12 col-lg-12">
    <div class="h4 invisible"></div>
    <div class="rxsignal-chart-bubble" ui-view="rxsignal-chart-bubble"></div>
    <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
            <span class="text-muted panel-title">
                {{ Drug.aedrug_name | pascalCaseFilter }} RxSignal
            </span>
                    <button class="btn btn-info btn-mini restoreSortButton pull-right"
                            ng-click="clearLocalStorage()"
                            popover-append-to-body="true" popover-trigger="mouseenter"
                            popover-placement="top" popover="Reload grid with default sorting order">
                        Restore Default Settings
                    </button>
                    <span id="rxsignal-filter-view" ui-view="rxsignal-filter"></span>
                </div>
                <div class="gridStyle" ng-grid="drugRxsignal.options" id="portfolio-rxsignal-grid"></div>
            </div>
        </div>
    </div>
</div>

<div ng-include="app/drug/partials/drug.rxsignal.update.modal.html"></div>

部分:

<!-- modal -->
<h1> test </h1>
<script type="text/ng-template" id="rxsignalUpdateModal.html">
    <div class="modal-header">
        <h3 class="modal-title letter-title">Modal Title</h3>
    </div>
    <div class="modal-body">
        <div class="letter-body">
            <p>text</p>
        </div>
    </div>
    <div class="modal-footer">
        <button class="btn btn-primary" ng-click="cancel()">OK</button>
    </div>
</script>
<!-- end modal -->

script/template 元素 (text/ng-template) 需要 id 属性上的前导“/”或其他路径才能正常工作。

右:<script type='text/ng-template' id='/my-template.html'>

错误:<script type='text/ng-template' id='my-template.html'>

请参阅 plunkr:http://plnkr.co/edit/BA26CP?p=preview

Angular 脚本文档:

https://code.angularjs.org/1.3.18/docs/api/ng/directive/script

解决方案需要进行一些更改。我删除了 ng-include 代码,并简单地在模态实例对象中添加了完整路径:

            var modalInstance = $modal.open({
                animation: true,
                templateUrl: 'app/common/partials/rxsignal-update-modal.html',
                controller: 'ModalInstanceCtrl',
                size: size
            });

然后,在部分模板中,我删除了脚本标签,因此它只是 html。