How to use Ionic components inside custom components/directives

You have to import the Ionic components and register them as ‘directives’ :

import {Component} from 'angular2/angular2';
import {List, Item} from 'ionic/ionic';

@Component({
    selector: 'test-list',
    templateUrl: 'app/test-list/test-list.html',
    directives: [List, Item]
})
export class TestList {
    constructor() {
    }
}

There is one thing missing still; I posted a question how to get a handle for those Ionic components inside the custom component – to use the methods. Seems the Ionic components inside a custom components do not register themselves into the IonicApp - so getComponent('id') is not working.

5 Likes