angularjs - ui.bootstrap 模式加载 html 但不显示任何内容

标签 angularjs angular-ui-bootstrap

其加载打开模式以及指定的加载模板。但没有显示任何内容。

在此处查看演示:http://demo.hupp.in/food-admin

前往 [产品] 并搜索 EnegiKcal >= 3500。然后单击管理。它将打开弹出窗口,但模板内容未加载。

我注意到的另一件事是它有时会为模板返回HTTP 304

这就是我打开模式的方式:

/** Open Modal For add edit tags */
$scope.open = function (productId) {

    var modalInstance = $modal.open({
        templateUrl: 'views/some.html',
        controller: tagsModalInstanceCtrl,
        size: 'lg'
    });

    modalInstance.result.then(function (msg) {

    }, function () {
        // $log.info('Modal dismissed at: ' + new Date());
    });

};  

var tagsModalInstanceCtrl = function ($scope, $modalInstance) {

    $scope.ok = function () {
        $modalInstance.close("hi");
    };

    $scope.cancel = function () {
        $modalInstance.dismiss('cancel');
    };
};

这是模板代码:

<div class="modal-header">
   <h3 class="modal-title">I'm a modal!</h3>
</div>
<div class="modal-body">
   <h3>Well, Hello there!</h3>
</div>
<div class="modal-footer">
    <button class="btn btn-primary" ng-click="ok()">OK</button>
    <button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>

enter image description here

enter image description here

最佳答案

好吧,这很奇怪,但看来你的模板是基于 https://github.com/angular-ui/bootstrap/blob/master/template/modal/window.html 的 master 分支

以及标签 0.11 上的来源。

https://github.com/angular-ui/bootstrap/blob/0.11.0/src/modal/modal.js

当您在控制台中输入 $('.modal-content') 时,它是可见的,您将看到它需要一个 modal-transclude 指令,但在源代码中没有该指令的踪迹。因为,在 0.11 上它直接使用 ng-transclude 指令,它是 Angular 的一部分。

因此,您的代码是正确的,但库不正确,请尝试检索它的正确版本(也许他们的存储库的最后一个版本已损坏)

关于angularjs - ui.bootstrap 模式加载 html 但不显示任何内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25952510/

相关文章:

javascript - $state.reload() 后无法与页面交互

javascript - 如何在列表中动态添加带有选项卡的元素。 Angular js

javascript - AngularJS 添加新项目并从列表中删除现有项目

php - Facade.php 第 216 行中的 FatalErrorException:调用未定义的方法 Illuminate\Foundation\Application::missing()

javascript - 传递的 Angular UI 模态数据为 null

css - Angular 2 + Material 2 : Sticky Footer with a md-toolbar

angularjs - 更新 angular-ui 中的引导下拉按钮值和操作

AngularJS UiBoostrap Accordion 。找不到指令 'uibAccordion' 所需的 Controller 'uibAccordionGroup'

html - Bootstrap 3 left close bar 100% height with container-fluid

angularjs - 使用angularjs ui bootstrap分页重新加载后如何留在当前页面上?