Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 离子2,ControlValueAccessor接口问题_Angular_Ionic2 - Fatal编程技术网

Angular 离子2,ControlValueAccessor接口问题

Angular 离子2,ControlValueAccessor接口问题,angular,ionic2,Angular,Ionic2,我在Angular中创建了一个自定义组件来搜索google places,如下图所示,下面的代码只是为了给你们一个想法 @Component({ selector: 'app-googleplace', templateUrl: './googleplace.component.html', providers: [ { provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => Googl

我在Angular中创建了一个自定义组件来搜索google places,如下图所示,下面的代码只是为了给你们一个想法

@Component({
  selector: 'app-googleplace',
  templateUrl: './googleplace.component.html',
  providers: [
    {
      provide: NG_VALUE_ACCESSOR,
      useExisting: forwardRef(() => GoogleplaceComponent),
      multi: true
    }
  ]
})
export class GoogleplaceComponent implements ControlValueAccessor {
/* rest of stuff */
  writeValue(value: GooglePlaceStruct) {
    // sets the value
  }

  registerOnChange(fn: any) {
    this.onChangeCallback = fn;
  }

  registerOnTouched(fn:any) {
    this.onTouchedCallback = fn;
  }
}
它在网站上运行良好, 现在,我正在将网站转换为ionic 2应用程序,当我将其与离子输入一起使用时,ControlValueAccessor接口方法从未被调用。


有指针吗?

尽管这已经很旧了:


Ionic用自己的()替换传递给Ionion input的任何
ControlValueAccessor
。这就是您的
ControlValueAccessor
从未被调用的原因。

尽管这已经很旧了:

Ionic用自己的()替换传递给Ionion input的任何
ControlValueAccessor
。这就是您的
ControlValueAccessor
从未被调用的原因