这个问题已经在这里有了答案:????????????>????????????angularjs unable to find templates directory, flask as backend????????????????????????????????????1个
当我尝试从模板文件夹加载注入的页面时,出现页面未找到错误. index.html页面是我启动服务器时默认启动的页面,它还包含ng-view,因此我可以注入angular配置中指定的页面.
这是我的项目结构:
angular_routing/
flask_service.py
static/
script.js
templates/
index.html
home.html
....
这是我的角度路由:
// configure our routes
scotchApp.config(function($routeProvider) {
$routeProvider
// route for the home page
.when('/', {
templateUrl : 'templates/home.html',
controller : 'mainController'
})
// route for the about page
.when('/about', {
templateUrl : 'templates/about.html',
controller : 'aboutController'
})
// route for the contact page
.when('/contact', {
templateUrl : 'templates/contact.html',
controller : 'contactController'
})
.otherwise({
templateUrl: '/',
controller: 'mainController'
});
// $locationProvider.html5Mode(true);
});
顺便说一句,我尝试给templateUrl加上’/’前缀,但是它也不起作用.