In Ionic 2, how do I create a custom directive that uses Ionic components?

前端 未结 1 626
故里飘歌
故里飘歌 2021-02-19 21:58

Creating a basic directive is simple:

import {Component} from \'angular2/core\';

@Component({
    selector: \'my-component\',
    template: \'
Hello!&
1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-19 22:39

    Found the answer here:

    You have to import the Ionic components and register them as 'directives'

    So my second example becomes:

    import {Component} from 'angular2/core';
    import {List, Item} from 'ionic/ionic';
    
    @Component({
        selector: 'my-component',
        directives: [List, Item],
        template: 'I am an item'
    })
    export class MyComponent {
        constructor() {
    
        }
    }
    

    0 讨论(0)
提交回复
热议问题