我正在尝试在angular2 / ionic2中创建一个包含输入的自定义组件,这里是代码:
- import {Component} from "angular2/core";
- import {ItemInput} from "ionic-framework/ionic";
- @Component({
- directives: [ItemInput],selector: "add-input",template: `
- <ion-input clearInput>
- <input type="text" value="">
- </ion-input>
- `
- })
- export class AddInput {
- constructor() { }
- }
问题是在最终页面/视图中似乎忽略了离子输入(没有应用样式,甚至无法点击它).如果我将代码移动到主视图,那么它的工作原理.向此自定义组件添加按钮时
- <button>ok</button>
并导入Button(并将其添加到此组件的指令列表中)这是有效的.所以我不确定是否需要特别注意要在自定义组件中使用的ItemInput组件,或者我是否只是遇到了一个bug.
使用离子2.0 alpha49.
有什么线索吗?
使用IONIC_DIRECTIVES导入离子指令:
- import {Component} from '@angular/core';
- import {IONIC_DIRECTIVES} from 'ionic-angular';
- @Component({
- selector: 'add-input',template: `
- <ion-input clearInput>
- <input type="text" value="">
- </ion-input>
- `,directives: [IONIC_DIRECTIVES]
- })
- export class AddInput {
- constructor() {}
- }