Open lostip opened 7 years ago
FYI, I was able to workaround both issues, although very hackishly, so it would still be very nice to have these requests added if possible.
angular.module('ui.router').config(['$stateProvider', function ($stateProvider) {
// Workaround for issue (1) without having to change host app's state names
// Real hack, since angular's decorator is not available for providers, I'm manually
// wrapping/overriding ui-router's state (registration) function
$stateProvider.state = _.wrap($stateProvider.state, function(func, stateName, definition) {
if(stateName === 'dashboard' && definition.parent === 'main') {
stateName = 'main.dashboard';
}
func(stateName, definition);
return $stateProvider;
});
// Workaround for issue (2)
// This uses a documented ui-router decorator, but it's still fragile since I'm hardcoding
// ng-admin's root state name, so updating ng-admin version will break this (this is an example
// for v0.9, where root state name is 'main', which already changed to 'ng-admin' in v1).
$stateProvider.decorator('parent', function(state, sooper) {
if(state.self && state.self.name === 'main') {
state.parent = 'admin';
}
return sooper(state);
});
}]);
Description
I want to use ng-admin as an extra module to my already existing app. There are two issues that are currently preventing me to do so:
1) Route name clashing [workaroundable]
ng-admin.
(i.e.ng-admin.dashboard
)2) I'd like ng-admin to live within one of the routes/states of my app [not workaroundable afaik]
Thanks!
P.S.: this project is great! 😃