找不到名字Select - Ionic 3

时间:2017-10-28 21:25:47

标签: angular ionic-framework ionic3

我遵循了本教程:https://forum.ionicframework.com/t/ion-select-with-icon/63059/10 检查上一个解决方案

我想在点击图标(放在标题上)时显示选择选项菜单 如下所示:

enter image description here

但是我收到了错误:无法找到姓名'选择',因为此版本失败。

<ion-buttons end> 
 <button ion-button icon-only (click)="someFunc()" >
  <ion-icon name="icon-name"></ion-icon>
 </button>
</ion-buttons>

<ion-select #sectionSelect (ngModel)="selecteTopic" [selectOptions]="selectOptions" (ionChange)="topicChange($event,selecteTopic)">
  <ion-option value="0" selected="true">topic A</ion-option>
  <ion-option value="1">topic B</ion-option>
  <ion-option value="2">topic C</ion-option>
  <ion-option value="3">topic D</ion-option>
  <ion-option value="4">topic E</ion-option>
  <ion-option value="5">topic F</ion-option>
  <ion-option value="6">topic G</ion-option>
  <ion-option value="7">topic H</ion-option>
</ion-select>

typescript文件

//Error here - cannot find name 'Select'
@ViewChild('sectionSelect') sectionSelect: Select;

selectOptions  =  {
  title: 'Location',
  subTitle: 'Select outlet location'
};

import { Component ,ViewChild } from '@angular/core';

someFunc(){
    this.sectionSelect.open();
    console.log('hello')
 }

1 个答案:

答案 0 :(得分:1)

确保导入Select

import { Select } from 'ionic-angular';