AngularJS - bind to directive resize

后端 未结 6 1833
Happy的楠姐
Happy的楠姐 2020-12-08 20:18

How can i be notified when a directive is resized? i have tried

element[0].onresize = function() {
            console.log(element[0].offsetWidth + \" \" +          


        
6条回答
  •  一整个雨季
    2020-12-08 21:21

    Use scope.$watch with a custom watch function:

    scope.$watch(
      function () {
        return [element[0].offsetWidth, element[0].offsetHeight].join('x');
      },
      function (value) {
        console.log('directive got resized:', value.split('x'));
      }
    )
    

提交回复
热议问题