Angular 已忽略RadListView ng模板
我正在尝试使用nativescript angular framework创建我的第一个移动应用程序。我被RadListView组件卡住了。当我尝试使用RadListView和来自数组的数据时,RadListView会为每个项目创建一个标签并绑定到它。当我提供自己的ng模板时,没有任何变化,数组的内容仍然像以前一样显示。我尝试了一个新项目,但问题仍然存在 代码 这是我在一个空白的新项目上尝试的代码: src\app\home\home.component.html 我试图验证ListView组件是否也出现了问题,但它工作正常。 我在这个链接上发现了一个类似的问题: 结果 RadListView结果 列表视图结果Angular 已忽略RadListView ng模板,angular,nativescript,ng-template,radlistview,Angular,Nativescript,Ng Template,Radlistview,我正在尝试使用nativescript angular framework创建我的第一个移动应用程序。我被RadListView组件卡住了。当我尝试使用RadListView和来自数组的数据时,RadListView会为每个项目创建一个标签并绑定到它。当我提供自己的ng模板时,没有任何变化,数组的内容仍然像以前一样显示。我尝试了一个新项目,但问题仍然存在 代码 这是我在一个空白的新项目上尝试的代码: src\app\home\home.component.html 我试图验证ListView组件
我忘了什么吗?我必须改变什么?你能设置一个游乐场吗?@F_Fuschi这里有一个非常基本的演示,你可以作为参考,谢谢大家的回答。我解决了将模块导入我的页面模块,而不仅仅是应用模块的问题。
<ActionBar class="action-bar">
<Label class="action-bar-title" text="Home"></Label>
</ActionBar>
<GridLayout tkExampleTitle tkToggleNavButton class="page">
<RadListView [items]="dataItems" background="red">
<ng-template tkListItemTemplate let-item="item">
<StackLayout orientation="vertical" background="blue">
<Label [text]="item" background="green"></Label>
<Label text="Template text to display!" ></Label>
</StackLayout>
</ng-template>
</RadListView>
</GridLayout>
import { Component, OnInit } from "@angular/core";
import { ObservableArray } from "tns-core-modules/data/observable-array";
@Component({
selector: "Home",
moduleId: module.id,
templateUrl: "./home.component.html"
})
export class HomeComponent implements OnInit {
private _dataItems: ObservableArray<string>;
constructor() {
// Use the component constructor to inject providers.
}
ngOnInit(): void {
// Init your component properties here.
this._dataItems = new ObservableArray(["Test", "Hello", "World"]);
}
get dataItems(): ObservableArray<string> {
return this._dataItems;
}
}
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
import { NativeScriptUIListViewModule } from "nativescript-ui-listview/angular";
import { AppRoutingModule } from "./app-routing.module";
import { AppComponent } from "./app.component";
@NgModule({
bootstrap: [
AppComponent
],
imports: [
NativeScriptModule,
AppRoutingModule,
NativeScriptUIListViewModule
],
declarations: [
AppComponent
],
schemas: [
NO_ERRORS_SCHEMA
]
})
export class AppModule { }