0
私はangularjsのアプリを書いていますが、私はメインコントローラの変数にアクセスする方法がわかりません。
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";
私はネストされたコントローラからユーザ名をアクセスしたい:
gsg_main.controller('testCtrl',['$scope',function($scope){
var self = this;
self.testvar = $scope.$parent.username;
}])。
私も試してみました:
self.testvar = $scope.$parent.parent.username;
私は他の記事で見ました。
メインコントローラで$ scopeを使用しない方法はありますか?
ありがとうございました。
あなたができました常にサービス間で値を共有するサービスを使用します。 – Lex