How to call a function on a directive scope from the controller

前端 未结 2 1447
感动是毒
感动是毒 2021-01-15 13:20

I\'ve searched all over the internet and cannot find a solution please help!

directive(\'menu\',function(){
    return{
        link : function(scope,element         


        
2条回答
  •  一个人的身影
    2021-01-15 14:01

    Delay the call to foo() using $evalAsync():

    controller : function($scope){
        $scope.$evalAsync(function() {
            $scope.foo();
            console.log($scope);
        });
    }
    

    fiddle

    You could also use $timeout() instead of $evalAsync(). Both allow the link function to execute first.

提交回复
热议问题