AngularJS - Access isolated scope in directive's link function

前端 未结 4 2121
北海茫月
北海茫月 2020-12-13 09:46

I\'m giving a first try at AngularJS custom directives.

I\'m having trouble using (or understanding ...) the isolated scope in the link function of the directive.

4条回答
  •  北荒
    北荒 (楼主)
    2020-12-13 10:10

    You can visit the JSFiddle created by me here: http://jsfiddle.net/7t984sf9/5/:

    link: function($scope, $elem, $attr) {
        console.log($scope.onewayObject);
        $attr.$observe('onewayObject', function(value) {
             console.log(value);
        });
    }
    

    Or some more detailed explanation here: What is the difference between & vs @ and = in angularJS

提交回复
热议问题