Move hasModelKey method to route instead of routeParams

This commit is contained in:
Joe Fiorini 2015-06-18 10:17:00 -04:00
parent 389eddfc8d
commit 13ab1120a9
3 changed files with 6 additions and 6 deletions

View File

@ -11,7 +11,7 @@ export default
'$routeParams',
function($rootScope, $routeParams) {
$rootScope.$on('$routeChangeStart', function(e, newRoute) {
wrapDelegate(newRoute.params);
wrapDelegate(newRoute);
});
$rootScope.$on('$routeChangeSuccess', function(e, newRoute) {

View File

@ -6,8 +6,8 @@
export function wrapDelegate($delegate) {
$delegate.hasModelKey = function hasModelKey(key) {
return $delegate.hasOwnProperty('model') &&
$delegate.model.hasOwnProperty(key);
return $delegate.params.hasOwnProperty('model') &&
$delegate.params.model.hasOwnProperty(key);
};
return $delegate;
@ -16,7 +16,7 @@ export function wrapDelegate($delegate) {
export default
[ '$provide',
function($provide) {
$provide.decorator('$routeParams', wrapDelegate);
$provide.decorator('$route', wrapDelegate);
}
];

View File

@ -33,7 +33,7 @@ export default {
'Rest',
'GetBasePath',
function($route, $q, rest, getBasePath) {
if ($route.current.params.hasModelKey('inventory')) {
if ($route.current.hasModelKey('inventory')) {
return $q.when($route.current.params.model.inventory);
}
@ -53,7 +53,7 @@ export default {
'Rest',
'GetBasePath',
function($route, $q, rest, getBasePath) {
if ($route.current.params.hasModelKey('hosts')) {
if ($route.current.hasModelKey('hosts')) {
return $q.when($route.current.params.model.hosts);
}