我应该怎么创建templateUrl财产的角度UI路由器的路径? [英] how should I create the path of templateUrl property in Angular ui-router?
问题描述
请,帮帮忙!
我试图找出为什么铬控制台返回我,找不到我的/home.html的模板 GET HTTP://本地主机:3000 / home.html的404(未找到)
。
我怕,我不是设置templateUrl属性的正确路径。
I'm trying to figure out why the chrome console returns me that it can't find my "home.html" template GET http://localhost:3000/home.html 404 (Not Found)
.
I'm afraid that I'm not setting correct the path of "templateUrl" property.
下面是我的文件夹结构:
Here is my folder structure:
app.js
bin/
node_modules/
package.json
public/
---------javascript/
-------------------angularApp.js
routes/
views/
----------index.ejs
----------home.html
这是我的配置code(位于angularApp.js)
and this is my config code(located in angularApp.js)
angular.module('supervisor', ['ui.router'])
.config([
'$stateProvider',
'$urlRouterProvider',
function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: '/home".html',
controller: 'MainCtrl'
});
$urlRouterProvider.otherwise('/home');
}
])
我也试过像../../home.html,但没有成功不同的路径。如果我使用内联模板它的工作(<脚本类型=文/ NG-模板ID =/ home.html做为>你好<!/ SCRIPT>
)。
感谢您!
推荐答案
这将您在使用前preSS以满足您的应用出现。防爆preSS是一种服务器端框架,同时棱角分明是一个客户端框架。你不应该混合2 code基地。您在使用的角度都应该充当静态资源。你很可能会提供您的公共文件夹的静态路由。因此,最有可能需要修改你的结构,像这样(我将如何构建它):
It would appear you're using express to serve your application. Express is a server side framework, while angular is a client side framework. You shouldn't mix the 2 code bases. Everything you use in angular should be served as static resources. You're very likely serving your public folder as static routes. So most likely you need to modify your structure like so (how I would structure it):
public
--app
----scripts
------angularApp.js
----views
------home.html
那么你的模板URL应/程序/视图/ home.html做为
这篇关于我应该怎么创建templateUrl财产的角度UI路由器的路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!