angularjs - How to let Parent refresh data if I add data in the child controller -


i need add data in teh child controller, after submit added data in child controller,i need parent controller reload data. here code sample:

 function parentctr(){        $scope.getreportsview = function() {             reportservice                 .getreportlistview(                     $scope.headerinfo.expensereportid)                 .then(                     function(reportinformation) {                         $scope.expensereports =    reportinformation.expenseslist.expreport;                         if ($scope.expensereports != null && $scope.expensereports.length > 0) {                             $scope.noexpense = false;                         }                     });         }; }  in child controller: have function like: $scope.adddata = function(data){    adddataservice.add(data).then(function()) } 

i using bootstrap $modal create add data popup, child controller thsi modal:

<div ng-contrlooer='parentctr'>  {{expensereports }}     <button ng-click='openpopup'>add data</> </div> 

waht want after add data in child controller, need let $scope.getreportsview() in parent controller run again refresh table. added data part of $scope.expensereports used in parent controller.

ok, after seeing code , html, , explanation of how you're calling child controller in modal, think what's going on here while logically have parent child relationship, no such relationship exists between controllers. if 1 does, `$scope.$parent should give access parent scope.

since doesn't seem case, suggestion call $scope.getreportsview "parent" scope when return modal.


Comments