ionic framework - ion-slide-box Update Issue -
<ion-slide-box> <ion-slide ng-repeat="imageurl in item.images"> <img ng-src="{{imageurl}}" /> </ion-slide> </ion-slide-box>
and controller:
$scope.changeitem = function(differentitem) { $scope.item = differentitem; //$scope.$apply(); $ionicslideboxdelegate.update(); };
whenever changeitem() button clicked, changes $scope.item use in ng-repeat(in slide-box).
my problem here $ionicslideboxdelegate.update();
doesn't update , set pager index 0 new number of images of selected item though $scope.item changes.
edit: indeed, seems known issue, noted on official ionic forum. however, made example work can see here. things i've changed following:
- i updated ionic version 1.0.1 (you can see links http://code.ionicframework.com/)
- used
$ionicslideboxdelegate.slide(0);
because otherwise fails again if click button when on last image - used
$ionicslideboxdelegate.update()
trying, inside$timeout
since (as read on forum) items not yet rendered when callupdate()
method on$ionicslideboxdelegate
;
updated code, here reference:
angular.module('ionicapp', ['ionic']) .controller('myctrl', function($scope, $http, $ionicslideboxdelegate, $timeout) { $scope.item = {}; $scope.item.images = [ 'http://lorempixel.com/400/200/', 'http://lorempixel.com/400/300/', 'http://lorempixel.com/400/400/', ]; $scope.changeimages = function(){ $ionicslideboxdelegate.slide(0); $scope.item.images = [ 'http://lorempixel.com/200/200/', 'http://lorempixel.com/300/300/' ]; $timeout(function(){ $ionicslideboxdelegate.update(); }, 500); }; });
<html ng-app="ionicapp"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>ionic template</title> <link href="http://code.ionicframework.com/1.0.1/css/ionic.min.css" rel="stylesheet"> <script src="http://code.ionicframework.com/1.0.1/js/ionic.bundle.min.js"></script> </head> <body ng-controller="myctrl"> <ion-slide-box show-pager="true"> <ion-slide ng-repeat="imageurl in item.images track $index"> <img ng-src="{{imageurl}}" /> <button class="button" ng-click="changeimages()">change imgs</button> </ion-slide> </ion-slide-box> </body> </html>
--edit end--
i made test project on codepen, , can see, changing images
on item
object updates accordingly.
so, without seeing rest of code, can't help. can make similar codepen example code, can see may wrong it.
code pasted here reference:
angular.module('ionicapp', ['ionic']) .controller('myctrl', function($scope, $http) { $scope.item = {}; $scope.item.images = [ 'http://lorempixel.com/400/200/', 'http://lorempixel.com/400/300/', 'http://lorempixel.com/400/400/', ]; $scope.changeimages = function(){ $scope.item.images = [ 'http://lorempixel.com/200/200/', 'http://lorempixel.com/300/300/', 'http://lorempixel.com/500/400/', ]; }; });
body { cursor: url('http://ionicframework.com/img/finger.png'), auto; }
<html ng-app="ionicapp"> <head> <meta charset="utf-8"> <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> <title>ionic template</title> <link href="http://code.ionicframework.com/0.9.25/css/ionic.min.css" rel="stylesheet"> <script src="http://code.ionicframework.com/0.9.25/js/ionic.bundle.min.js"></script> </head> <body ng-controller="myctrl"> <ion-header-bar title="mytitle"></ion-header-bar> <ion-pane class="has-header" padding="true"> <h2>you can't see me</h2> </ion-pane> </body> </html>
Comments
Post a Comment