I am having problem with ion-slide-box implementation
I want to achieve two way binding as below
Two way binding with out ionic slidebox
Any help appreciated
Thanks
I found the solution. There might better way to fix it but i can only think of this at the moment
I have to modify ion-slide-box directive a bit
Here is my code:
Ionic bundle.js (Create two way Binding here)
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>
If there is better way please let me know
Thanks