【问题标题】:Ionic modal popup is not working离子模式弹出窗口不起作用
【发布时间】:2017-08-01 06:08:00
【问题描述】:

我刚刚开始研究 ionic 版本 1,并添加了一个打开模式的代码,但它没有打开任何模式。它给了我这个错误:-“加载资源失败:net::ERR_FILE_NOT_FOUND”。以下是我的代码:-

  // Load the modal from the given template URL
        $ionicModal.fromTemplateUrl('pages/modal/memberid/memberid.html', {
      scope: $scope,
      animation: 'slide-in-up'
   }).then(function(modal) {
      $scope.modal = modal;
   });

   $scope.openModal = function() {
      $scope.modal.show();
   };

   $scope.closeModal = function() {
      $scope.modal.hide();
   };

   //Cleanup the modal when we're done with it!
   $scope.$on('$destroy', function() {
      $scope.modal.remove();
   });

   // Execute action on hide modal
   $scope.$on('modal.hidden', function() {
      // Execute action
   });

   // Execute action on remove modal
   $scope.$on('modal.removed', function() {
      // Execute action
   });
   $ionicModal.show();

我在 www/pages/modal/memberid/memberid.html 文件夹中创建了一个 html 文件:-。它显示有关找不到模板文件的错误

【问题讨论】:

    标签: ionic-framework


    【解决方案1】:

    您指定的文件路径不正确,请先尝试使用浏览器解决它。


    作为替代解决方案,您可以尝试在 html 本身上使用嵌入式模板

     <script id="modal.html" type="text/ng-template">some modal code</script>
    

    并在您的 javascript 中使用 modal.html 作为 url

    【讨论】:

    • 在哪里添加上面的脚本?
    • 您可以将其添加到您指定控制器的html页面中
    • 我使用了错误的路径 "id="templates/wapFeedModal.html", id="wapFeedModal.html" 为我工作。
    猜你喜欢
    • 1970-01-01
    • 2023-03-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-03-17
    • 2023-03-18
    • 2012-08-22
    相关资源
    最近更新 更多