如何在AngularJS渲染后再加载JS

http://www.itnose.net/detail/6100484.html

 

app.directive('repeatDone', function () {
    return function (scope, element, attrs) {
        var input = element.find('.calendar .calendarInput');
        input.datepicker({ changeMonth: true, changeYear: true, maxDate:0});
        element.find('.calendar .calendarButton').click(function () {
            input.trigger("focus");
        });
        if (scope.$last) { // all are rendered
            scope.$eval(attrs.repeatDone);
        }
    }
});


app.directive('onFinishRenderFilters', function ($timeout) {
    return {
        restrict: 'A',
        link: function (scope, element, attr) {
            if (scope.$last === true) {
                $timeout(function () {
                    scope.$emit('ngRepeatFinished');
                });
            }
        }
    };
});

 

posted @ 2016-01-21 14:14  zcynine  阅读(395)  评论(0编辑  收藏  举报