2017-07-18 13 views
0

がライブラリ内で失敗しました。がtns_modulesにあり、this._androidは未定義です。プレーンなnativescriptでのAPI呼び出しが機能しているので、角DOMでAPIを呼び出すにはどうすればよいですか?

_createUI()とは決して呼ばれていないようです。

エラー:

TypeError: Cannot read property 'addHeart' of undefined File: "file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules//bundles/core.umd.js, line: 13024, column: 8

StackTrace: Frame: function:'PeriscopeHearts.addHeart', file:'file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules/nativescript-periscopehearts/periscopehearts.js', line: 19, column: 22 Frame: function:'WebRtcViewComponent.newHeart', file:'file:///data/data/org.nativescript.bbnsng210June/files/app/modules/webrtcview/webrtcview.component.js', line: 39, column: 24 Frame: function:'', file:'', line: 81, column: 24 Frame: function:'handleEvent', file:'file:///data/data/org.nativescript.bbnsng210June/files/app/tns_modules//bundles/core.umd.js', line: 11805, column: 138

呼び出し元のコードはこれです:

@ViewChild('heartLayout') heartLayout_el: ElementRef; 
    ngAfterViewInit(): void { 
    this.peri_heart_el_native = <PeriscopeHearts>(this.heartLayout_el.nativeElement); 
    alert('this.peri_heart_el_native:' + this.peri_heart_el_native); //PeriscopeHearts(771) 
    } 
    newHeart() { 
    let colorArray = [{ hex: "#3489db" }, { hex: '#FF4081' }, { hex: '#229911' }, { hex: '#fff000' }]; 
    let rand = colorArray[Math.floor(Math.random() * colorArray.length)]; 
    this.peri_heart_el_native.addHeart(rand.hex); 
    } 

とテンプレート:

<side-drawer-page> 
    <StackLayout class="coverImage"> 
    <Button text="Add Heart" (tap)="newHeart()"></Button> 
    <PeriscopeHearts #heartLayout class="heartLayout" height="400"> 
    </PeriscopeHearts> 
    </StackLayout> 
</side-drawer-page> 

PS:pluginのgithubの問題が作成されているが、それはですここで複製されたプラグインに固有の問題よりも、より多くの角度の問題があります。

答えて

0

heartLayout

例えばへの参照をつかむためにloadedイベントを使用してみてくださいあなたのHTML

<PeriscopeHearts (loaded)="onLoaded($event)" class="heartLayout" height="400"> 
+0

同じ結果、同じエラーで

onLoaded(args) { this.peri_heart_el_native = <PeriscopeHearts>args.object; } 

。 – ishandutta2007

関連する問題