ionic-team / ionic-framework

A powerful cross-platform UI toolkit for building native-quality iOS, Android, and Progressive Web Apps with HTML, CSS, and JavaScript.
https://ionicframework.com
MIT License
50.94k stars 13.52k forks source link

Expression 'undefined' used with directive 'ionSlides' is non-assignable! #6036

Closed shahroon closed 8 years ago

shahroon commented 8 years ago

The error started to appear when I switched from Ionic-1.0.0-beta.14 to Ionic-1.2.4. I was using ion-slide-box before and now switched to ion-slides.

    <ion-content class="has-header has-footer">
        <ion-slides change="slideHasChanged($index)" pager="false">
            <ion-slide-page ng-show="currentView === 'today'">
                <myDashboardOrder clientOrders="todaysOrders"></myDashboardOrder>
            </ion-slide-page>

            <ion-slide-page ng-show="currentView === 'upcoming'">
                <myDashboardOrder clientOrders="upcomingOrders"></myDashboardOrder>
            </ion-slide-page>

            <ion-slide-page ng-show="currentView === 'past'">
                <myDashboardOrder clientOrders="pastOrders"></myDashboardOrder>
            </ion-slide-page>

        </ion-slides>
    </ion-content>

Which Ionic Version? 1.x or 2.x 1.2.4

Run ionic info from terminal/cmd prompt: (paste output below) Cordova CLI: 5.4.1 Ionic Version: 1.2.4 Ionic CLI Version: 1.7.14 Ionic App Lib Version: 0.7.0 OS: Distributor ID: Ubuntu Description: Ubuntu 14.04.4 LTS Node Version: v0.12.4

shahroon commented 8 years ago

Never mind, fixed it. I was not using the watcher on slider. Now struggling with removing pager and on-slide-change kind of options.

turbulence commented 8 years ago

@shahroon

Hi, have the same error happening on my side since I upgrade to 1.3.0. Can you tell me what you means by "not using the watcher on slider" and how you fixed it?

Thanks

shahroon commented 8 years ago

@turbulence Do something like this,

        $scope.sliderOptions = {
            effect: 'slide',
            paginationHide: true,
            initialSlide: 0,
            onInit: function(swiper){
                $scope.swiper = swiper;
            },
            onSlideChangeEnd: function(swiper){
                // ....
            }
        };

and on template something like this, <ion-slides options="sliderOptions" slider="swiper"> // ....

Hope this will help.

turbulence commented 8 years ago

@shahroon

Thanks so much, it works!

Here's what I add to my code:

$scope.options =
{
loop: false,
pagination: false,
onInit: function(swiper)
{
$scope.data.swiper = swiper;
},
...

And in my template file:

<ion-slides pager="false" options="options" slider="data.slider">

Thanks again

shahroon commented 8 years ago

Glad it helped.

Hezhenli commented 7 years ago

@shahroon Thanks so much, it works!

ionitron-bot[bot] commented 6 years ago

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.