【问题标题】:$uibModal templateUrl does not change modal content$uibModal templateUrl 不改变模态内容
【发布时间】:2019-01-24 04:28:57
【问题描述】:

全部! 我正在制作一个 Angular 应用程序,并希望实现一个简单的模式窗口弹出窗口,这将允许用户“构建”一个 URL。

我的页面如下所示:

这是触发我的按钮的 URL 按钮(第三行)的 HTML。

<button class="btn btn-secondary" ng-click="vm.showUrlModal()" id="button-url-to-modal" type="button" title="Hyperlink &lt;a&gt; Ctrl+L"><img src="/images/url.png" height="18px"/></button>

处理页面的控制器如下所示:

(function() {
    function postchallengeController($uibModal, newChallengeData) {
        var vm = this;
        vm.message = "Post a challenge!";
        vm.showUrlModal = function() {
          $uibModal.open({
            templateUrl: '/url_modal/url_modal.view.html',
            controller: 'url_modal',
            controllerAs: 'vm',
          })
     }
     postchallengeController.$inject = ['$uibModal', 'newChallengeData'];

     /* global angular */
     angular
       .module('stackunderflow')
       .controller('postchallengeController', postchallengeController);
})();

以及引用的 url_modal 控制器:

(function() {
  function url_modal($uibModalInstance) {
    var vm = this;


    vm.modal = {
      cancel: function() {
        $uibModalInstance.close();
      }
    };
  }
  url_modal.$inject = ['$uibModalInstance'];

  /* global angular */
  angular
    .module('stackunderflow')
    .controller('url_modal', url_modal);
})();

在引用的文档 (/url_modal/url_modal.view.html) 中是一个简单的 Hello World,它应该在我打开模式时显示 - 但是,当我这样做时,页面会打开一个覆盖当前内容的模式在它之上。

请看这里:

我做错了什么?

谢谢!

编辑:我的 index.html 中确实引用了两个控制器,并且我的模块确实包含 ['ui.bootstrap']

【问题讨论】:

    标签: angularjs angularjs-scope angular-ui-bootstrap single-page-application mean-stack


    【解决方案1】:

    错误可能隐藏在 html 文件的引用中。

    确保/url_modal/ 目录的父目录设置为您使用 express.static 函数调用设置的根文件夹。

    【讨论】:

    • 哇,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-05-25
    • 2015-09-24
    • 2014-08-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多