Angularjs 离子滑盒双向绑定不工作
我对离子滑盒的实现有问题 我想实现双向绑定,如下所示 谢谢你的帮助Angularjs 离子滑盒双向绑定不工作,angularjs,ionic-framework,ion-slide-box,Angularjs,Ionic Framework,Ion Slide Box,我对离子滑盒的实现有问题 我想实现双向绑定,如下所示 谢谢你的帮助 谢谢,我找到了解决办法。也许有更好的方法来解决这个问题,但我现在只能想到这一点 我必须稍微修改一下离子滑盒指令 这是我的密码: Ionic bundle.js(在此处创建双向绑定) 指令.js directive('updateCounter', function(){ return{ restrict : 'A', scope : false, require : '^ionSlideBox',
谢谢,我找到了解决办法。也许有更好的方法来解决这个问题,但我现在只能想到这一点 我必须稍微修改一下离子滑盒指令 这是我的密码: Ionic bundle.js(在此处创建双向绑定) 指令.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);
})
}
}})
$scope.$on(
"IncrementValue",
function handleIncrementValue() {
$scope.counter++;
}
);
$scope.triggerEvent = function() {
$scope.$broadcast( "IncrementValue" );
};
ViewController.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);
})
}
}})
$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>
增量框
减量箱
如果有更好的办法,请告诉我
谢谢仍在等待解决方案