angularjs directive指令link在渲染完成之后执行

原创
半兽人 发表于: 2020-02-16   最后更新时间: 2020-02-16 21:46:19  
{{totalSubscript}} 订阅, 1,633 游览

借用setTimeout()函数实现,在指令渲染完成之后,执行需要执行的函数。

export default class {

    /*@ngInject*/
    constructor() {
        thi
    constructor() {
        thi.restrict = 'E';
        this.scope = {
            ngSrc: '@ = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style = {
            ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id}} class = {
            ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout         ngSrc     ngSrc: '@'
        };
        this.template = `<div class="player" layout="column    ngSrc'@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id}} class="flowplayer">
                            </div>
                         </div>`;
    }
    link(scope, element = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px      ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style = {
            ngSrc: '@'
        };
        this.template = {
            ngSrc: '@'
        };
        this.template = {
            ngSrc: '@'
        };
        this.template = `<div = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player          ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column            ngSrc '@    };
        this};
        this.template = `<div class="player" layout="column"  layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id = {
            ngSrc: '@'
        };
        this.template = `<div class="player          ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id}} class="flowplayer">
                            </div>
                         </div>`;
    }
    link(scope, element, attrs, ngModelController) {
        scope.id = 'flow = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player          ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc '@    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id}} class            ngSrc    };
        this = {
            ngSrc: '@'
        };
        this.template = `<div = {
            ngSrc: '@'
        };
        this.template = `<div class="player = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column = {
            ngSrc: '@'
        };
        this.template = `<div class          ngSrc = {
            ngSrc: '@'
        };
        this.template = `<div class="player" layout="column"  layout-align="center center" style="height:190px">
                            <div id={{id}} class="flowplayer">
                            </div>
                         </div>`;
    }
    link(scope, element, attrs, ngModelController) {
        scope.id = 'flow-player-' + Math.floor(Math.random()*10000);
        scope.init = function () {
            flowplayer(scope.id, FlowPlayerPlay, {
                clip: {
                    url:attrs.ngSrc ,
                    autoPlay: false,
                    autoBuffering: true
                }
            });

        };
        setTimeout(function(){
            scope.init();
        },0);
    }
}
更新于 2020-02-16

查看AngularJS更多相关的文章或提一个关于AngularJS的问题,也可以与我们一起分享文章