laravel Angular UI-Router templateUrl 问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27630460/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Angular UI-Router templateUrl Issue
提问by Austin
I am still learning the UI-Router for AngularJS and have was hoping to get some help. I am taking advantage of the nested views functionality, but running into some hiccups. My top level parent state works, but as soon as I start creating children, the template URL's start acting up. Its as if the templateUrl's aren't dynamic to their top level parent. Am I naming the template/view files incorrectly? I did my best to follow the sample contacts app provided on the repo.
我仍在学习 AngularJS 的 UI-Router 并希望得到一些帮助。我正在利用嵌套视图功能,但遇到了一些小问题。我的顶级父状态有效,但是一旦我开始创建子级,模板 URL 就开始起作用。就好像 templateUrl 对其顶级父级不是动态的。我是否错误地命名了模板/视图文件?我尽力遵循 repo 上提供的示例联系人应用程序。
projectsApp.js
项目App.js
var app = angular.module('scynergyApp.projects', ['ui.router']);
app.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouteProvider){
$stateProvider
//////////////
// Projects //
//////////////
.state('projects',{
url: '/projects',
templateUrl: 'app/projects/projects.html' // THIS TEMPLATE URL WORKS
})
/////////////////////////
// Projects > Details ///
/////////////////////////
.state('projects.details', {
url: '/details',
templateUrl: 'app/projects/projects.details.html' // THIS TEMPLATE URL DOESNT WORK -> only if its '../app/projects/projects.details.html'
})
///////////////////////////////////
// Projects > Details > Overview //
///////////////////////////////////
.state('projects.details.overview', {
url: '/overview',
templateUrl: 'app/projects/projects.details.overview.html' // THIS TEMPLATE URL DOESNT WORK -> only if its '../app/projects/projects.details.html'
});
}]);
File tree
文件树
public
app
projects
ProjectsController.js
projectsApp.js //dependency of app.js
projects.html
projects.details.html
projects.details.overview.html
app.js
Any direction on this would be greatly appreciated. Thank you
对此的任何方向将不胜感激。谢谢
采纳答案by bahadir
you should better use absolute paths mapping from project root like /app/projects/blabla
您应该更好地使用来自项目根目录的绝对路径映射,例如 /app/projects/blabla