angular - 子项目primeng上的角度下拉选择菜单错误
问题描述
我一直在尝试使用角度和反应形式(角度 10)在表单中设置子项的选择下拉菜单,但我尝试哪种方法(ng-select、角度多选、CdkVirtualScrollViewport 等)并不重要我可以' t 似乎可以这样做。我只能做一个普通的 HTML 选择,但由于下拉列表包含 5K 项,整个加载大约需要 6 秒,这是不可接受的。我正在尝试的最新是primeng的下拉列表,但即使是这个例子似乎也不起作用,下面是我的问题的一个片段......
ts.file contains
interface City {
name: string,
code: string
}
...
export class CreateFullOrderComponent implements OnInit {
...
cities: City[];
selectedCity: City;
....
constructor(
.....
this.cities = [
{name: 'New York', code: 'NY'},
{name: 'Rome', code: 'RM'},
{name: 'London', code: 'LDN'},
{name: 'Istanbul', code: 'IST'},
{name: 'Paris', code: 'PRS'}
];
......
HTML file..
....
<td>
<p-dropdown [options]="cities" [(ngModel)]="selectedCity" optionLabel="name"></p-dropdown>
</td>
......
the built works fine, however I get the following error in my chrome console..
main-es2015.41e78b833c373dc8af88.js:152077 ERROR TypeError: Cannot read property '_rawValidators' of null
at getControlValidators (main-es2015.41e78b833c373dc8af88.js:5144)
at setUpValidators (main-es2015.41e78b833c373dc8af88.js:5764)
at setUpControl (main-es2015.41e78b833c373dc8af88.js:5689)
at FormGroupDirective.addControl (main-es2015.41e78b833c373dc8af88.js:8877)
at NgModel._setUpControl (main-es2015.41e78b833c373dc8af88.js:8298)
at NgModel.ngOnChanges (main-es2015.41e78b833c373dc8af88.js:8258)
at NgModel.rememberChangeHistoryAndInvokeOnChangesHook (main-es2015.41e78b833c373dc8af88.js:147472)
at callHook (main-es2015.41e78b833c373dc8af88.js:148484)
at callHooks (main-es2015.41e78b833c373dc8af88.js:148451)
at executeInitAndCheckHooks (main-es2015.41e78b833c373dc8af88.js:148402)
我的形象看起来像......
我不确定这是否重要,但我在大多数其他尝试过的下拉菜单中都遇到了这个错误,我的理解是问题出在 [(ngModel)]="selectedCity" 上,就好像我删除了我赢得的那个声明'没有得到错误,即使它仍然下拉不工作。
我很感激任何帮助推进这个..
解决方案
推荐阅读
- php - 我想通过 Linklist Collection 展示产品?
- javascript - 在 AspNetCore 中使用 Rotativa 将 Html 转换为 Pdf
- php - 如何使用带有 Scrapy 的 admin-ajax.php 从网站上抓取数据
- javascript - 向循环firebase云功能中的所有电子邮件发送电子邮件
- c# - 我的应用程序 SQL 连接在 iOS 上不起作用,但在 MacOS windows android 和统一编辑器中
- php - 带有通配符的 MySQLi 准备语句的奇怪结果(程序)
- sql-server - 在 sql server 中替换的情况
- javascript - jQuery,克隆元素并替换其名称的一部分
- reactjs - 如何为非反应应用程序构建反应组件
- hyperledger-fabric - 来自尝试的对等通信的响应是一个错误:链码错误