0

I have several nested directives. I now need to invoke a function in deep child.

<parent-directive>
    <child-directive>
        <deep-child-directive></deep-child-directive>
    </child-directive>
</parent-directive>

I want call method in deep-child-directive controller from parent-directive controller. Is there any way except $broadcast to do this?

my function:

$scope.refreshProductSearch = function() {
    var isRefresh = true;
    if( $rootScope.urlOption.query  ) {
        var selected = $rootScope.urlOption.query;
        if( $rootScope.urlOption.query) {
            var urlOption = util.jsonUrlParser(selected);
            isRefresh = urlOption.query.searchs ? false : true;
        }
    }
    if( isRefresh ) {
        $scope.clearValues();
    }
    $scope.$emit("removeAdvanceSearch");
};
davood Sandoghsaz
  • 674
  • 1
  • 4
  • 13
  • Possible duplicate of [AngularJs 1.5 - Component does not support Watchers, what is the work around?](http://stackoverflow.com/questions/35534479/angularjs-1-5-component-does-not-support-watchers-what-is-the-work-around). See the demo of [**Use RxJS in a Service**](https://plnkr.co/edit/Y2hQkAC74JeY9WO1OxpV?p=preview) – georgeawg Mar 27 '17 at 08:57
  • Hi George, thanks for your response, I edit my post and add that function. Function use $scope and $rootscope, can I change that to service method? – davood Sandoghsaz Mar 27 '17 at 13:47

0 Answers0