Jquery spritespin integration with angular js

Jquery spritespin integration with angular js

本文关键字:angular js with integration spritespin Jquery      更新时间:2023-09-26

I new to angular js.我想用角度 js 实现。

这是我的代码。

索引.html

<div class="container" ng-controller="headerController">
    <span ng-repeat="b in button" > 
         <button button-control id='{{b}}' ng-click = '{{b}}()'>{{b}}</button>
    </span>
</div>

应用.js

.controller('headerController',function($scope,$location){
     $scope.button = ['prev','toggle','reserve','next'];
 })
.directive('buttonControl',function(){
    return{
      restrict: 'AE',
      replace: true,
      link:function(scope,elem,attrs){
      var api = elem.spritespin('api');
      scope.prev = function(){               
       api.stopAnimation(); //**problem**
      }
      scope.toggle = function(){
      }
      scope.reserve = function(){
      }
      scope.next = function(){
      }
  }
}

})

问题当我做api.stopAnimation()时,stopAnimation()使用这个指向当前范围而不是elem的对象。我可能错了。

任何帮助表示赞赏

谢谢

我通过chrome AngularJS Batarang,我必须做

scope.$parent.$parent.api = new Object 

覆盖父范围

现在在按钮控制器指令中。我可以通过做

 app.directive('buttonControl',function(){
    return{
    restrict: 'AE',
    replace: true,
    link:function(scope,elem,attrs){
        console.log(scope.api);
    }
})