角度模态服务不识别templateUrl

时间:2016-12-20 13:42:19

标签: angularjs service modal-dialog

  

https://github.com/dwmkerr/angular-modal-service

当我想显示模态时,控制台会显示此错误

GET http://localhost:3000/copy/duplicate_view.html 404 (Not Found)

控制器上的

(function() {
  'use strict';
  function editCtrl($scope, appSettings,pricingService, ModalService) {

    $scope.show = function() {
      ModalService.showModal({
        templateUrl: '../copy/duplicate_view.html',
        controller: "DialogDemoCtrl"
      })
    };
  }

  angular.module('myApp')
    .controller('editCtrl', editCtrl)
  ;
})();

在HTML上:

 <a class="btn-green-alt btn" href ng-click="show()">{{'dialog.EXPORT' | translate}}</a>

依赖

angular
  .module('myApp', [
    'daterangepicker',
    'angular-loading-bar',
    'ui.tinymce',
    'angularModalService'
  ])

这就是我在服务代码上看到的......

  var getTemplate = function getTemplate(template, templateUrl) {
    var deferred = $q.defer();
    if (template) {
      deferred.resolve(template);
    } else if (templateUrl) {
      $templateRequest(templateUrl, true).then(function (template) {
        deferred.resolve(template);
      }, function (error) {
        deferred.reject(error);
      });
    } else {
      deferred.reject("No template or templateUrl has been specified.");
    }
    return deferred.promise;
  };

1 个答案:

答案 0 :(得分:0)

使用..

设置模板whitout的绝对路径

修改 根据您对项目结构的评论

app
  specifications
    copy
      duplicate_view.html

然后将templateUrl设置为

templateUrl: 'app/specifications/copy/duplicate_view.html',