<div ng-controller="myaccountctrl"> <div ng-controller=" Transferctrl" > ....... </div> </div>
//children pass data to parent level//Child Pass- through$scope. Checkloggedin =function (type) {$scope. TransferType=type; $scope. $emit ('Transfer.type', type); } //Parent Receive$scope. $on ('Transfer.type', Function (Event, data) {$scope. TransferType=data; }); $scope. Checkloggedin=function () {varType =$scope. TransferType; }
//Parent passes data to child//Parent Pass- through$scope. TransferType ="'; $scope. Checkloggedin=function (type) {$scope. TransferType=type; $scope. $broadcast ('Transfer.type', type); } //Child receive$scope. TransferType ="'; $scope. $on ('Transfer.type', Function (Event, data) {$scope. TransferType=data; }); $scope. Checkloggedin=function () {varType =$scope. TransferType; }
Online Example: http://each.sinaapp.com/angular/apps/app-broadcast.html
AngularJs Parent-child controller pass data