Ionic image carousel

Source: Internet
Author: User

Ionic image carousel

1. Using ion-slide can achieve image carousel. However, adding only ion-slide in html is far from enough. There are two problems:

(Note: angularjs is used. First, inject $ ionicSlideBoxDelegate into the js file)

1. Sometimes images cannot be loaded. Solution:

Add $ ionicSlideBoxDelegate. update () in the corresponding controller file ();

2. The solution to the last non-Carousel problem is:

Add $ ionicSlideBoxDelegate. loop (true) in the corresponding controller file );

The Code is as follows:

1 function getMessageInface () {2 vm. condition = {// input parameter 3 "sysid": 1000, 4 "token": "sfiodfndsig" 5}; 6 Service. post ('advertisement ', 'findeffectivedatainfo', vm. condition ). then (function (data) {7 8 console. log (data) 9 vm. ADlists = data; 10 angular. forEach (vm. ADlists, function (index) {11 // statements12 // console. log ("cyclically add imgurl"); 13 if (index. pic. indexOf ("http") <0) {14 index. pic = vm. imgUrl + index. pic; 15 // console. log (index. pic) 16} 17}); 18 $ ionicSlideBoxDelegate. loop (true); // solves the problem of not carousel to the last one 19 $ ionicSlideBoxDelegate. update (); // solve the problem of image loading failure 20}); 21 22 23}

The injection method is as follows:

 

(Function (){
Angular. module ('app'). controller ('goodslistctrl ', goodsListCtrl );
GoodsListCtrl. $ inject = ['$ scope', '$ statstate', 'service',' $ stateParams ',' $ localstore', '$ ionicSlideBoxDelegate', '$ ionicPopup'];

 

Function goodsListCtrl ($ scope, $ state, Service, $ stateParams, $ localStorage, $ ionicSlideBoxDelegate, $ ionicPopup ){
Var vm = this;

......

......

}

})();

 

 

3. Use $ ionicSlideBoxDelegate. loop (true) will have a problem that has not yet been understood: when loading two images, four will be displayed, that is, two will be repeated, and other situations are normal. So my final solution is to achieve manual carousel according to official documents ......

 



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.