【发布时间】:2016-12-16 12:24:58
【问题描述】:
我正在尝试使用 NativeScript 进行一些实验,但我遇到了一些奇怪的错误,我无法理解这一点。
我的组件中有一个简单的口袋妖怪列表:
import {Component} from '@angular/core';
import {Http} from '@angular/http';
@Component({
selector:'pokemon-list',
templateUrl: 'components/pokemonList/pokemonList.html'
})
export default class PokemonList {
pokemons: Array<any>;
constructor(private http:Http){
this.pokemons = [
{name: 'Bulbi', url: 'google.com'}
];
}
}
并且关联了以下模板:
<StackLayout>
<Label text="Pokemons" class="h1 text-center"></Label>
<ListView [items]="pokemons">
<template let-item="pokemon">
<pokemon-item [name]="pokemon.name" [url]="pokemon.url"></pokemon-item>
</template>
</ListView>
</StackLayout>
当我尝试启动应用程序时,我的控制台中出现以下错误:
Error in components/pokemonList/pokemonList.html:4:20 caused by: undefined is not an object (evaluating 'self.parentView.context.pokemon.name')
我做错了什么? :/
【问题讨论】:
标签: javascript angular typescript nativescript