I have the following configuration, I have a config where a url is called using $http.get method and the data is stored in a variable "alpha". How do I access this variable from the controller. I tried to inject $rootScopeProvider into the config and tried to set $rootScope.pqr = alpha. This gives an error. How do I do it?
angular.module('thisApp', [someDependencies]).config( function($stateProvider, $urlRouteProvider) {
$http.get('url').then(function(response) {
var alpha = response.data; // i need to access this data in the controller
)};
}).directive('pqrTitle', function () {
return {
restrict: 'A',
controller: function($scope, $rootScope) {
// I need to access alpha here
});
});
How do I do this?