【发布时间】:2014-04-20 14:24:50
【问题描述】:
我正在开发一个 anuglar + nodejs 应用程序并遇到了这个问题。我想设置以下url映射:
localhost:3000/ => 节点服务器在服务器端提供 index.html,然后在客户端提供部分视图 index.html(有两个 index.html 一个在服务器端一个客户端) localhost:3000/signup => angular routeProvider 将部分视图 signup.html 服务到 index.html(ajax 所以无需重新加载)
localhost:3000/customerLoggedin =>节点服务器为 customerLoggedin.html 服务,也许 Angular 服务于其他部分(页面重新加载) localhost:3000/customerLoggedin/order-form => angular routeProvider 提供部分视图 order.html (ajax)
我有以下代码:
角边:
system.js:
angular.module('myApp.system').config(['$stateProvider', '$urlRouterProvider','$locationProvider',
function($stateProvider, $urlRouterProvider,$locationProvider) {
// For unmatched routes:
$urlRouterProvider.otherwise('/');
// states for my app
$stateProvider.state('home', {
url: '/',
templateUrl: 'public/system/views/partials/index.html' // there are two index.html one on the server side (which is the layout) and one served by angular
}).state('signup',{
url:'/signup',
templateUrl:'public/system/views/partials/signup.html'
}).state('payment',{
url:'/payment',
templateUrl:'public/system/views/partials/payment.html',
controller:'paymentCtrl'
}).state('order',{
url:'/order-form',
templateUrl:'public/system/views/partials/order.html',
controller:'orderCtrl'
});
}
])
customerLoggedin.html:
...
<a href='/order-form'><span>New Order</span></a>
...
<section data-ui-view ng-view class='view-animate'/>
...
节点服务器上的路由:
module.exports = function(app){
app.get('/customerLoggedIn',function(req,res){
res.render('customerLoggedIn');
});
app.get('/',function(req,res){
res.render('index');
});
};
现在的问题是,当我点击 customerLoggedin.html 中的“新订单”链接时,角度给了我 client-sdie index.html,它应该只显示在 localhost:3000/index.html 中。我希望 Angular 将部分视图 order.html 提供给 customerLoggedin.html 中的 ngview
如何做到这一点?
提前致谢
【问题讨论】:
标签: javascript html node.js angularjs