2015-02-11 75 views
0

这里是我的应用程序,试图使用用户界面模式,但当模态功能不能找到HTML模板。我可以控制日志里面的功能,但不能打开模态视图。我的角度用户界面模式不能找到模板

var app = angular.module('myApp', [ 
     'angularUtils.directives.dirPagination', 

    'ui.bootstrap' 
    ]); 


    app.controller('galleryCtrl', ['$scope', '$http', function ($scope, $http) { 

    }]). 
    controller('ModalInstanceCtrl',['$scope','$modal',function($scope, $modalInstance){ 

    }]). 
    directive('myGallery', function ($http,$modal) { 
     return { 
      restrict: 'E', 
      scope: { 
       feed: '@', 
       search: '=?', 
       resultsPerPage: "=?", 
       sorting: "=?" 
      }, 
      templateUrl: './MyGallery.tpl.html', 
      link: function (scope, element, attrs) { 


       scope.search = scope.search || true; 
       scope.sorting = scope.sorting || true; 
       scope.resultsPerPage = scope.resultsPerPage || 10; 

       console.log(scope.resultsPerPage); 

       scope.openModal = function() { 


        var modalInstance = $modal.open({ 
         templateUrl: '/views/modal.html', 
         controller: 'ModalInstanceCtrl' 
        }); 
       }; 
在HTML

<div class="imgs"> 
    <ul> 
     <li dir-paginate="img in imgs 
     | filter:query 
     | itemsPerPage: resultsPerPage.value || 10 "> 
       <a href=""><img ng-src="{{img.url}}" ng-click="openModal()"></a> 
     </li> 
    </ul> 
</div> 

,这就是我得到:

GET http://localhost:63342/views/modal.html 404 (Not Found) 

的路径是100%正确的,所以如果能跟大家可以看到有什么问题。

+0

如果您在浏览器中直接访问http:// localhost:63342/views/modal.html,它会将模板拉出来? – duhseekoh 2015-02-11 18:37:23

+0

不,这就是根:mainFolder - > views - > modal.html和index.html中的mainFolder – 2015-02-11 18:57:37

+0

右..所以路径是不正确的。 '''templateUrl:'yourmainfolder/views/modal.html''''? – duhseekoh 2015-02-12 20:15:54

回答

0

只是为了确保..尝试:

templateUrl: 'views/modal.html', 

也许你的本地服务器的文档根目录,你觉得是不是这样的。

摆脱初始斜杠,确保路径相对于角项目的根文件夹。

+0

我得到这个没有/:GET http:// localhost:63342/front_testV2/template/modal/window.html 404(Not Found),我根本不知道这个根。有任何想法吗 ? – 2015-02-11 19:00:15

+0

您必须将您的服务器根目录配置为角项目的根目录。 – joanllenas 2015-02-12 11:35:18