I am writing an app with angularjs and I don't know how to access the variables in my main-controller.
gsg_main.controller('mainCtrl',['$scope','SessionService','$http','$routeParams','MessageService','$interval','$location','orderByFilter',function($scope,SessionService,$http,$routeParams,MessageService,$interval,$location,orderBy){
//variablen
var self = this;
self.username = "any_name";
I want to access username from a nested controller:
gsg_main.controller('testCtrl',['$scope',function($scope){
var self = this;
self.testvar = $scope.$parent.username;
}]);
I also tried:
self.testvar = $scope.$parent.parent.username;
which I found in other posts.
Is there a way without using $scope in the main-controller?
Thanks for your help.