There are two addresses in the router:
when('/:userName', { resolve: { //сюда прилетают данные только по юзеру userdata: resolves.userdata }, templateUrl: '/partials/userPage.html', controller: 'userCtrl' }). when('/magazine/:magazineName', { resolve: { //сюда прилетают данные по юзеру и журналу magazine: resolves.magazine, userdata: resolves.userdata }, templateUrl: '/partials/magazine.html', controller: 'magazineCtrl' controllerAs: 'vm', }) you need to combine them in one
when('/:objName', { resolve: { magazine: resolves.magazine, userdata: resolves.userdata }, templateUrl: '/partials/magazine(userPage).html', controller: 'magazineCtrl(userCtrl)' }) and use parameter checking through the service, so that depending on the response of the service, the total route dynamically changes
.service('userOrMagazine', ['$route', '$q', 'tools', function($route, $q, tools) { var params = $route.current.params, objName= params.objName? params.objName: null, q = $q.defer(); if (!objName) q.reject(); tools.data.get(api.RESOLVE.format(objName)).then(function(data) { // data.type равен 'users или 'magazines' return q.resolve(data.type); }); return q.promise; }]); Any thoughts on how to implement this?
controller: 'magazineCtrl(userCtrl)'levelcontroller: 'magazineCtrl(userCtrl)'- Grundy