ionic-framework icon indicating copy to clipboard operation
ionic-framework copied to clipboard

<ion-item-sliding> inside a custom component

Open jalef opened this issue 10 years ago • 4 comments

Short description of the problem The <ion-item-sliding> component does not work if it is used inside a custom component

What behavior are you expecting? When using the <ion-item-sliding> component inside an <ion-list>, the item slides and the option buttons are revealed. When I use the exact same code inside a custom component and I create an <ion-list> by repeating the custom component (which includes the <ion-item-sliding>) , the item does not slide.

Steps to reproduce:

  1. create an ionic project, version 2
  2. create a component with the following template: <ion-item-sliding> <ion-item> <h2>Slimer</h2> </ion-item> <ion-item-options> <button secondary> <ion-icon name="call"></ion-icon> Call </button> </ion-item-options> </ion-item-sliding>
  3. on a page, create a list that includes the component you created on step 2
  4. run ionic serve and try to slide the item

Which Ionic Version? 2.0.0-beta.23

Run ionic info from terminal/cmd prompt: Cordova CLI: 5.4.1 Gulp version: CLI version 3.9.0 Gulp local: Local version 3.9.1 Ionic Version: 2.0.0-beta.3 Ionic CLI Version: 2.0.0-beta.23 Ionic App Lib Version: 2.0.0-beta.13 OS: Node Version: v4.2.4

jalef avatar Apr 08 '16 16:04 jalef

Hello! Thanks for opening an issue with us! So when you say custom component do you mean your creating a custom angular2 component (using this decorator @Component) or are you creating an ionic page component (using @Page)?

jgw96 avatar Apr 08 '16 18:04 jgw96

Hello! I am creating a custom angular2 component , with the decorator @Component

Thanks!

jalef avatar Apr 09 '16 08:04 jalef

@jalef You need to import IONIC_DIREVTIVES for any custom component that uses an Ionic component.

import {IONIC_DIREVTIVES} from 'ionic-angular';
...
@Component({
   template: ....,
  directives: [IONIC_DIREVTIVES]
})

http://ionicframework.com/docs/v2/faq/#Angular_component

mhartington avatar Apr 10 '16 15:04 mhartington

thanks!

jalef avatar Apr 11 '16 14:04 jalef