我正在开发anuglar + nodejs应用程序并遇到此问题。我想建立以下URL映射:根URL更改时重定向到不同的路由
本地主机:3000/=>节点服务器上的服务器侧用作index.html,然后然后anuglar担任客户端局部视图的index.html(有两个索引。 HTML一个在服务器侧的一个客户端) 本地主机:3000 /注册=>角routeProvider用于局部视图signup.html成的index.html(AJAX所以没有重装)
本地主机:3000/customerLoggedin =>节点服务器服务customerLoggedin.html,也许角度服务于其他部分(页面重新加载) localhost:3000/customerLoggedin/order-form =>角度routeProvider服务partial view order.html(a JAX)
我有以下代码:
角侧:
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角的“新秩序”链接给我的客户sdie的index.html应该只在本地主机显示:3000/index.html的。我想棱角服务部分视图order.html到customerLoggedin.html中的ngview
如何实现这一目标?
在此先感谢
这可能工作,但你怎么解决这个问题时,浏览器首先加载HTTP状态变化:// localhost:3000/customerLoggedIn/angular认为它是“/”并加载index.html? –
如果localhost:3000/customerLoggedIn是一个不同的呈现html,它将基本上是一个不同角度的应用程序,具有不同的状态集合。您的替代方案是将/ customerLoggedIn作为从index.html提供的主角应用中的另一条路由 –