Reputation: 5356
I am trying to put 2 (or more) angular apps on the same NodeJS server. Basically what I want is:
I am using ui-router ($stateProvider) to create the routes and load the pages. The thing is that I want to be able to write relative paths on my apps so that if I need to rename the base url from clientapp to client, I don't need to change all my apps urls.
// this should be routed to admin/clients. Relative path
state('listClients', {
url: '/clients',
templateUrl: 'modules/clientes/views/list-clients.client.view.html'
}).
// this is how I am currently doing.
state('listClients', {
url: '/admin/clients',
templateUrl: 'modules/clientes/views/list-clients.client.view.html'
}).
The other strange thing that is happening is that when I set my angular app to a url, it kill the last / and add #! directly on the app name:
mydomain.com/app
becomes mydomain.com/app#!/main // ugly as hell
wanted mydomain.com/app/#!/main // little better
How can I:
Upvotes: 0
Views: 1114
Reputation: 51
First App folder
app.use('/', express.static(path.join(__dirname + '/app1')));
Second App folder
app.use('/crm', express.static(path.join(__dirname + '/app1/app2')));
Done! Enjoy
Upvotes: 1
Reputation: 991
1.You can try ui.router.stateHelper
angular.module('admin', ['ui.router', 'ui.router.stateHelper'])
.config(function(stateHelperProvider){
stateHelperProvider.setNestedState({
name: 'admin',
url: '/admin',
templateUrl: 'admin.html',
children: [
{
name: 'listClients',
url: '/clients',
templateUrl: 'clients.html'
}
]
});
});
once you want to change the module to clientapp you just need to change the module name and the url
angular.module('clientapp', ['ui.router', 'ui.router.stateHelper'])
.config(function(stateHelperProvider){
stateHelperProvider.setNestedState({
name: 'clientapp',
url: '/clientapp',
templateUrl: 'clientapp.html',
children: [
{
name: 'listClients',
url: '/clients',
templateUrl: 'clients.html'
}
]
});
});
2.As for the ugly issue,I have no idea about it.Sorry for that.
Upvotes: 0