我開發一個Web應用程序就是這樣:Node.js的不加載AngularJS意見
- project
--- app
------ controllers
------ views
------ app.js
--- public
------ assets
--------- css
--------- js
--------- img
--- index.html
...我的index.html裏面我有基本的HTML,鏈接,腳本標籤。所有加載角應用程序和一切工作正常。
但現在,我需要使用Node.js加載所有的應用程序。
所以首先我將index.html移動到public /並創建一個新文件。
index.js(Node.js的)
app.use("/", express.static(path.join(__dirname, 'public')));
app.get('/', function(req, res) {
res.sendFile(path.join(__dirname + '/index.html'));
});
app.listen(3000, function() {
console.log('Example app listening on port 3000!');
});
辦刊我在瀏覽器控制檯得到了Node.js的:
GET http://localhost:3000/app/views/layouts/public.html 404 (Not Found)
這是我如何加載我的角度觀點
app.config(function($urlRouterProvider, stateHelperProvider) {
$urlRouterProvider.otherwise('/');
$urlRouterProvider.when('', '/');
stateHelperProvider.state({
name: 'public',
title: 'Home',
url: '/',
controller: 'PublicCtrl',
templateUrl: '/app/views/layouts/public.html',
data: {
requireLogin: false
}
})
.state({
name: 'private',
controller: 'PrivateCtrl',
templateUrl: '/app/views/layouts/private.html',
data: {
requireLogin: true
},
children: [
{
name: 'browse',
title: 'Home',
url: '/browse',
templateUrl: '/app/views/browse/index.html',
controller: 'BrowseCtrl'
}
]
});
});
我沒有看到你指示的node.js服務於你的觀點,你都寫過。 –
我沒有,我只是指示node.js index.html。其餘的應該是繼續工作,這是不。 – Pablo
如果你不指示node.js服務它,它不會。 –