[英]redirect to different route when root url changes
我正在开发一个anuglar + nodejs应用程序,并遇到了这个问题。 我想设置以下网址映射:
localhost:3000 / =>节点服务器在服务器端提供index.html,然后在客户端提供auglar部分视图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中的“新订单”链接时,angular给了我一个client-sdie index.html,它应该只显示在localhost:3000 / index.html中。 我希望有角将部分视图order.html放到customerLoggedin.html的ngview中
如何实现呢?
提前致谢
尝试ui-sref指令来触发状态更改,而不是指向url
<a ui-sref='order'>New Order</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.