ion-slide-box 双向绑定不起作用

ion-slide-box two way binding not working

我在 ion-slide-box 实现方面遇到问题

Link to sample not working

我想实现如下两种方式的绑定

Two way binding with out ionic slidebox

感谢任何帮助

谢谢

我找到了解决方案。可能有更好的方法来修复它,但我现在只能想到这个

我必须稍微修改一下 ion-slide-box 指令

这是我的代码:

Ionic bundle.js(在此处创建双向绑定)

IonicModule.directive('ionSlideBox', [........,
   function(...){
       return{
         scope:{
          counter: "=",
          ...... 
        },
        controller: [.....,function(){
         _this.getCounter = function(){   
            return $scope.counter;   
          }

         _this.setCounter = function(val){
             scope.counter = val;
             $scope.$broadcast( "IncrementValue" );
          }
        }]
   }
}

Directive.js

directive('updateCounter', function(){
return{
    restrict : 'A',
    scope : false,
    require : '^ionSlideBox',
    link : function(scope,element, attrs,ctrl){
        $(element).click(function(){
            scope.counter = ctrl.getCounter();
            scope.counter--;
            ctrl.setCounter(scope.counter);
        })
    }
}})           

ViewController.js

$scope.$on(
  "IncrementValue",
  function handleIncrementValue() {
        $scope.counter++;
  }
);
$scope.triggerEvent = function() {
  $scope.$broadcast( "IncrementValue" );
};

View.html

 <ion-slide-box counter="counter">
     <ion-slide>
       <button ng-click="trigger()">Increment box</button>
       <button update-counter>Decrement box</button>
     </ion-slide>
 </ion-slide-box>

如果有更好的方法请告诉我

谢谢