如何在使用 angularjs 进行 http 调用后 运行 owl 轮播

How to run owl carousel after http call with angularjs

嗨,我有一个抛出 owl 旋转木马指令的工厂,但是我有一个工厂调用服务器获取我需要绘制容器旋转木马 owl 的数据,我该怎么做在调用 $http 完成后获取我绘制旋转木马 owl ?我的代码如下

指令

    app.directive('wrapOwlcarousel',['$timeout',function ($timeout) {  
    return {  
        restrict: 'E',  
        link: function (scope, element, attrs) { 

                 $timeout(function () {
                    scope.$emit('ngRepeatFinished');
                    var options = scope.$eval($(element).attr('data-options'));  
                    $(element).owlCarousel(options);
                    alert('carouel')
                });
        }  
    };  
]});

控制器

 app.controller('HomeController',[
    '$scope','$location','$timeout','Storage',function($scope,$location,$timeout,Storage){

        $timeout(function(){

            angular.element('#footer').css({
                'bottom' : '0'
            })

        },100);

        $scope.getClass = function(path) 
        { 
            if ($location.path().substr(0, path.length) == path){
                    if (path == "/" && $location.path() == "/") { return "active"; }
                    else if (path == "/") {  return ""; }

                    return "active" 

            } else { return "" } 
        }

        var items = Storage.has('posts');

        if(items){
            $scope.eventos = Storage.get('posts');
        }else{
            alert('no info')
        }


    }
]);

工厂

app.factory('EventFunctions',['$http','appSettings',function($http,appSettings){
    return {
        getAllPosts : function(){

            return $http.get(appSettings._url).then(function(result) {
               return result.data;
           });

        }
    }

}]);

感谢大家!

我找到答案了!

我的指令有语法错误,这是我的新指令文件

app.directive('wrapOwlcarousel',['$timeout',function ($timeout) {  
    return {  
        restrict: 'E',  
        link: function (scope, element, attrs) { 

                 $timeout(function () {
                    var options = scope.$eval($(element).attr('data-options'));  
                    $(element).owlCarousel(options);
                });


        }  
    };  
}]);