0

This is my UI Code

<div ng-controller="WorkFlowController" ng-init="init()">
  <div ng-controller="templatecontroller">
     <ul class="ng-scope" ng-click="child(1)"></ul>
 </div>
</div>

This is my script in app.js

This is my parent Controller

 app.controller("WorkFlowController",  function ($scope) {
  $scope.parentFuntion = function (TaskId) {
   };
 });

This is my child Controller

 app.controller("templatecontroller",  function ($scope) {
 $scope.child = function (TaskId) {
 parentFuntion(TaskId);
};
  });

My issue is that,I got the id in the child controller function but not able to pass to the parent. Is it possible to pass the id to parent controller function from the child..? Please help me :) Thanks in Advance

Prasanth S
  • 179
  • 1
  • 1
  • 9

2 Answers2

0

Check out this Stack Overflow Answer, It contains a lot of great information.

Using $scope you can use the $parent attribute to access the parent scope as such:

$scope.child = function (TaskId) {
    $scope.$parent.parentFuntion(TaskId);
}
Michael Lynch
  • 1,743
  • 15
  • 27
0

parent Controller

app.controller("WorkFlowController", function ($scope) { 

$rootScope.parentFuntion = function (TaskId) { }; });

child Controller

app.controller("templatecontroller", function ($scope) { $scope.child = function (TaskId) { $rootScope.parentFuntion(TaskId); }; });
siva kumar
  • 569
  • 1
  • 3
  • 13