Nativescript 填充RadaAutoCompleteTextViewComponent时出错

Nativescript 填充RadaAutoCompleteTextViewComponent时出错,nativescript,Nativescript,我在尝试填充RadAutoCompleteTextView时遇到以下错误。 这方面有什么暗示吗 非常感谢 @ViewChild("rankingsCtrl", { static: false }) rankingsCtrl: RadAutoCompleteTextViewComponent; this.rankingsCtrl.autoCompleteTextView.insertTokenAtIndex(new TokenModel("Test",""), 0); JS: ERROR

我在尝试填充RadAutoCompleteTextView时遇到以下错误。 这方面有什么暗示吗

非常感谢

@ViewChild("rankingsCtrl", { static: false }) rankingsCtrl: RadAutoCompleteTextViewComponent;


this.rankingsCtrl.autoCompleteTextView.insertTokenAtIndex(new TokenModel("Test",""), 0);


JS: ERROR Error: Uncaught (in promise): TypeError: Cannot read property 'addTokenModelAt' of undefined
JS: TypeError: Cannot read property 'addTokenModelAt' of undefined
JS:     at RadAutoCompleteTextView.push.../node_modules/nativescript-ui-autocomplete/ui-autocomplete.js.RadAutoCompleteTextView.insertTokenAtIndex (file:///node_modules/nativescript-ui-autocomplete/ui-autocomplete.js:589:0)

不建议在ngOnInit上访问元素或其方法,因为不能保证创建了底层nativeElement

尝试使用组件的
loaded
事件,以确保创建元素。
timeout
可能会起作用,但我不建议这样做,因为它不是一直都能保证的


如果您想访问多个元素,那么等待父视图的加载事件就足够了,所有子元素都应该在那时创建并准备好使用。

您何时调用
insertTokenAtIndex
?请在下面找到拼图中缺少的部分:this.rankingDaoService.findRankingsByPlayerId(this.idPlayer).then(val=>{for(let i=0;i