AngularJS access parent scope from child controller

前端 未结 9 1723
南方客
南方客 2020-11-22 07:30

I\'ve set up my controllers using data-ng-controller=\"xyzController as vm\"

I have a scenario with parent / child nested controllers. I have no problem

9条回答
  •  不思量自难忘°
    2020-11-22 07:51

    Super easy and works, but not sure why....

    angular.module('testing')
      .directive('details', function () {
            return {
                  templateUrl: 'components/details.template.html',
                  restrict: 'E',                 
                  controller: function ($scope) {
                        $scope.details=$scope.details;  <=== can see the parent details doing this                     
                  }
            };
      });
    

提交回复
热议问题