Angular Nativescript。角度2+;打字稿。将子对象添加到播放
我不能把孩子加入我的游戏。以下是我的choose_time.html:Angular Nativescript。角度2+;打字稿。将子对象添加到播放,angular,typescript,nativescript,addchild,Angular,Typescript,Nativescript,Addchild,我不能把孩子加入我的游戏。以下是我的choose_time.html: <WrapLayout #wrapLayout> </WrapLayout> 我做错了什么?当使用TypeScript感知编辑器且TS支持已正确配置时,您将在代码的最后一行看到错误 将其更改为(this.wrapLayout.nativeElement).addChild(标签)它就像一个老板!这里的关键是添加.nativeElement当使用支持TypeScript的编辑器并且TS支持配置正确时,
<WrapLayout #wrapLayout>
</WrapLayout>
我做错了什么?当使用TypeScript感知编辑器且TS支持已正确配置时,您将在代码的最后一行看到错误
将其更改为
(this.wrapLayout.nativeElement).addChild(标签)代码>它就像一个老板!这里的关键是添加.nativeElement
当使用支持TypeScript的编辑器并且TS支持配置正确时,您将在代码的最后一行看到错误
将其更改为(this.wrapLayout.nativeElement).addChild(标签)代码>它就像一个老板!这里的关键是添加.nativeElement
import { Component, ElementRef, ViewChild } from "@angular/core";
import { WrapLayout } from 'ui/layouts/wrap-layout'
import labelModule = require("ui/label");
@Component({
selector: "choose_time",
providers: [],
templateUrl: "pages/choose_time/choose_time.html",
styleUrls: ["pages/choose_time/choose_time-common.css"]
})
export class ChooseTimeComponent implements OnInit {
@ViewChild("wrapLayout") wrapLayout: ElementRef;
constructor(
private page: Page) {}
ngOnInit() {
this.page.actionBarHidden = true;
this.setChildren()
}
setChildren(){
var label = new labelModule.Label();
label.text = "text";
this.wrapLayout.addChild(label)
}