错误升级angular2 beta-15 - >公测-17

时间:2016-05-02 22:03:17

标签: angular

我在Angular2 beta-15上运行了一个应用程序,但随后我将其更新为beta-17,现在有一个难以破译的错误。

setCharacterAt(int index, char c)

1 个答案:

答案 0 :(得分:0)

如果您使用DynamicComponentLoader,则使用已更改为

export class DclWrapper {
  // get `ViewContainerRef` using `@ViewChild()` or by injecting it 
  // if the component itself should be the target
  @ViewChild('target', {read: ViewContainerRef}) target;
  @Input() type;
  cmpRef:ComponentRef;
  private isViewInitialized:boolean = false;

  constructor(private dcl:DynamicComponentLoader) {}

  updateComponent() {
    // should be executed every time `type` changes but not before `ngAfterViewInit()` was called 
    // to have `target` initialized
    if(!this.isViewInitialized) {
      return;
    }
    if(this.cmpRef) {
      throw 'currently changing type after the component was added is not supported'
    }
    // LoadIntoLocation was renamed and now takes a `ViewContainerRef`
    // instead of `ElementRef` and `target`
    this.dcl.loadNextToLocation(this.type, this.target).then((cmpRef) => {
      this.cmpRef = cmpRef;
    });
  }

  ngOnChanges() {
    this.updateComponent();
  }

  ngAfterViewInit() {
    this.isViewInitialized = true;
    this.updateComponent();  
  }
}