Nativescript+;Angular2:RadListView绑定

Nativescript+;Angular2:RadListView绑定,nativescript,angular2-nativescript,nativescript-telerik-ui,Nativescript,Angular2 Nativescript,Nativescript Telerik Ui,我试图将一个可观察对象绑定到RadListView,而不使用任何页面属性,但似乎做了一些完全错误的事情。以下是该代码的简化版本 组成部分: export class WeatherComponent implements OnInit { public weather : ObservableArray<StringWrapper>; constructor(private _weatherService : WeatherService) { th

我试图将一个可观察对象绑定到RadListView,而不使用任何页面属性,但似乎做了一些完全错误的事情。以下是该代码的简化版本

组成部分:

export class WeatherComponent implements OnInit {
    public weather : ObservableArray<StringWrapper>;

    constructor(private _weatherService : WeatherService) {
        this.weather = new ObservableArray<StringWrapper>([]);
        this.weather.push(<StringWrapper>{value:'Sunny'});
    }

    ngOnInit(): void {
        this._weatherService.getDummyWeather().subscribe(
            item => {
                this.weather.push(item);
            }
        );
    }
}
服务:

@Injectable()
export class WeatherService {
    public getDummyWeather() : Observable<StringWrapper> {
        return Observable.of(<StringWrapper>{value:'Rainy'});
    }
}
@Injectable()
出口级天气预报服务{
public getDummyWeather():可观察{
返回可观测值({value:'Rainy'});
}
}
服务正在正确地更新模型,但视图没有反映更改,这使我相信问题在于可观察的绑定

任何帮助都将不胜感激

注意:检查了相关问题,但没有任何解决方案有帮助,即解决方案导致生成错误。

将HTML更改为

 <RadListView  [items]="weather" >
        <template tkListItemTemplate let-item="item">
            <StackLayout class="itemStackLayout" >
                <Label class="titleLabel" [text]="item.value" textWrap="true" width="100%"></Label>
            </StackLayout>
        </template>
 </RadListView>

提示:似乎不需要stringwrapper。如果它只是一个字符串数组,您可以使用下面的代码

 <Label class="titleLabel" [text]="item" textWrap="true" width="100%"></Label>

将HTML更改为

 <RadListView  [items]="weather" >
        <template tkListItemTemplate let-item="item">
            <StackLayout class="itemStackLayout" >
                <Label class="titleLabel" [text]="item.value" textWrap="true" width="100%"></Label>
            </StackLayout>
        </template>
 </RadListView>

提示:似乎不需要stringwrapper。如果它只是一个字符串数组,您可以使用下面的代码

 <Label class="titleLabel" [text]="item" textWrap="true" width="100%"></Label>


此绑定
text=“{{value}}”
仅用于表示没有角度的NativeScript的XML。使用{N}+Angular时,您需要使用Angular的biding语法,即
[text]=“value”
@VladimirAmiorkov感谢您的回复和帮助!我修改了代码以考虑角度绑定(我假设Angular2的插值在以前被使用过),但是没有用;用户界面仍然不能反映这些变化。我已经在Github上比较了您的示例代码,但没有发现任何差异。此绑定
text=“{{value}}”
仅用于表示没有角度的NativeScript的XML。使用{N}+Angular时,您需要使用Angular的biding语法,即
[text]=“value”
@VladimirAmiorkov感谢您的回复和帮助!我修改了代码以考虑角度绑定(我假设Angular2的插值在以前被使用过),但是没有用;用户界面仍然不能反映这些变化。我已经在Github上比较了您的示例代码,但没有发现任何差异。您好,谢谢您的回复。不幸的是,这似乎没有任何区别,因为UI仍然无法更新。关于StringWrapper类,这只是为了演示。您好,谢谢您的回复。不幸的是,这似乎没有任何区别,因为UI仍然无法更新。关于StringWrapper类,它只是用于演示目的。