角度 – 在自定义组件内使用离子输入

前端之家收集整理的这篇文章主要介绍了角度 – 在自定义组件内使用离子输入前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试在angular2 / ionic2中创建一个包含输入的自定义组件,这里是代码
  1. import {Component} from "angular2/core";
  2. import {ItemInput} from "ionic-framework/ionic";
  3.  
  4.  
  5. @Component({
  6. directives: [ItemInput],selector: "add-input",template: `
  7. <ion-input clearInput>
  8. <input type="text" value="">
  9. </ion-input>
  10. `
  11. })
  12. export class AddInput {
  13. constructor() { }
  14. }

问题是在最终页面/视图中似乎忽略了离子输入(没有应用样式,甚至无法点击它).如果我将代码移动到主视图,那么它的工作原理.向此自定义组件添加按钮时

  1. <button>ok</button>

并导入Button(并将其添加到此组件的指令列表中)这是有效的.所以我不确定是否需要特别注意要在自定义组件中使用的ItemInput组件,或者我是否只是遇到了一个bug.

使用离子2.0 alpha49.

有什么线索吗?

使用IONIC_DIRECTIVES导入离子指令:
  1. import {Component} from '@angular/core';
  2. import {IONIC_DIRECTIVES} from 'ionic-angular';
  3.  
  4. @Component({
  5. selector: 'add-input',template: `
  6. <ion-input clearInput>
  7. <input type="text" value="">
  8. </ion-input>
  9. `,directives: [IONIC_DIRECTIVES]
  10. })
  11.  
  12. export class AddInput {
  13. constructor() {}
  14. }

猜你在找的Angularjs相关文章