I have a selection of controllers:
Controller1
Controller2
Controller3
I also have a service which all of my Controllers call. At the moment at the top of every Controller ive created a scope declaring the Controller name:
$scope.ControllerName = 'Page1Controller';
I then pass this scope into the service:
$scope.$parent.Description = serviceMydata.getDescription($scope.ControllerName).toString();
Is there a way to not have to declare $scope.ControllerName?
My service:
app.service('serviceMydata', function(){
return {
getDescription: function(ControllerName) {
return [
mapData[ControllerName]
];
}
}
});
var mapData = {
Page1Controller : 'Data to insert when on Page1',
Page2Controller : 'Data to insert when on Page2',
Page3Controller : 'Data to insert when on Page3',
Page4Controller : 'Data to insert when on Page4',
}