can i inherit a parent controller's variables?

后端 未结 5 750
北恋
北恋 2021-02-01 15:34

Here is my code:

function ParentCtrl($scope) {
$scope.people = [\"Tom\", \"Dick\", \"Harry\"];
$scope.count = $scope.people.length;
}

function ChildCtrl($scope)         


        
5条回答
  •  我在风中等你
    2021-02-01 15:56

    Also you can get the Scope of any controller by DOM:

    $needleScope = angular.element(aDomElement).scope()
    

    Using jQuery:

    $needleScope = $('#aDomElementId').scope()
    

    Or get all Scope in the document:

    $allScopes = $('.ng-scope').scope()
    

提交回复
热议问题