这里是我的应用程序,试图使用用户界面模式,但当模态功能不能找到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%正确的,所以如果能跟大家可以看到有什么问题。
如果您在浏览器中直接访问http:// localhost:63342/views/modal.html,它会将模板拉出来? – duhseekoh 2015-02-11 18:37:23
不,这就是根:mainFolder - > views - > modal.html和index.html中的mainFolder – 2015-02-11 18:57:37
右..所以路径是不正确的。 '''templateUrl:'yourmainfolder/views/modal.html''''? – duhseekoh 2015-02-12 20:15:54