2
0
Fork 0
tcrud/lib/www_views/node-ff-tcrud/angular/js/navigation-service.ejs

58 lines
1.1 KiB
Plaintext
Raw Permalink Normal View History

2017-06-10 14:53:29 +00:00
'use strict';
tcrudUI.factory('navigationService', ['$route', '$rootScope',
function($route, $rootScope) {
var actions = {
save: null,
cancel: null,
open: null,
delete: null,
create: null,
refresh: null
};
var resetActions = function() {
for (var key in actions) {
if (key.indexOf('Impl') > 0) {
continue;
}
actions[key] = null;
}
};
actions.saveImpl = function() {
actions.save();
resetActions();
};
actions.cancelImpl = function() {
actions.cancel();
resetActions();
};
actions.openImpl = function() {
actions.open();
resetActions();
};
actions.deleteImpl = function() {
actions.delete();
resetActions();
};
var pageTabs = [];
var pageTitle = '';
var pageLocations = [];
$rootScope.$on('$routeChangeSuccess', function() {
pageTabs = [];
pageTitle = '';
pageLocations = [];
resetActions(); // to late gives flikering..
//$rootScope.$apply();
});
return {
actions: actions,
pageTabs: pageTabs,
pageTitle: pageTitle,
pageLocations: pageLocations,
};
}
]);