Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 角度下拉菜单选择子项打底错误_Angular_Forms_Lazy Loading_Dropdown - Fatal编程技术网

Angular 角度下拉菜单选择子项打底错误

Angular 角度下拉菜单选择子项打底错误,angular,forms,lazy-loading,dropdown,Angular,Forms,Lazy Loading,Dropdown,我一直在尝试使用angular和Responsive forms(angular 10)在表单中设置子项的选择下拉菜单,但无论我尝试哪种方法(ng select、angular multiselect、CdkVirtualScrollViewport等),我似乎都无法做到这一点。我只能做一个普通的HTML选择,但由于下拉列表包含5K个项目,整个加载过程大约需要6秒钟,这是不可接受的。我正在尝试的最新一个例子是Priming的下拉列表,但即使是这个例子也似乎不起作用,下面是我的一个问题片段。。

我一直在尝试使用angular和Responsive forms(angular 10)在表单中设置子项的选择下拉菜单,但无论我尝试哪种方法(ng select、angular multiselect、CdkVirtualScrollViewport等),我似乎都无法做到这一点。我只能做一个普通的HTML选择,但由于下拉列表包含5K个项目,整个加载过程大约需要6秒钟,这是不可接受的。我正在尝试的最新一个例子是Priming的下拉列表,但即使是这个例子也似乎不起作用,下面是我的一个问题片段。。

ts.file包含
接口城市{
名称:string,
代码:字符串
}
...
导出类CreateFullOrderComponent实现OnInit{
...
城市:城市[];
所选城市:城市;
....
建造师(
.....
这是一个城市=[
{名称:'纽约',代码:'纽约'},
{名称:'Rome',代码:'RM'},
{名称:'London',代码:'LDN'},
{名称:'伊斯坦布尔',代码:'IST'},
{名称:'Paris',代码:'PRS'}
];
......
HTML文件。。
....
......
构建的工作正常,但是我在chrome控制台中遇到以下错误。。
main-es2015.41e78b833c373dc8af88.js:152077错误类型错误:无法读取null的属性“\u rawValidators”
在getControlValidators(main-es2015.41e78b833c373dc8af88.js:5144)
at设置验证器(main-es2015.41e78b833c373dc8af88.js:5764)
at设置控制(main-es2015.41e78b833c373dc8af88.js:5689)
at FormGroupDirective.addControl(main-es2015.41e78b833c373dc8af88.js:8877)
at NgModel.\u设置控制(main-es2015.41e78b833c373dc8af88.js:8298)
位于NgModel.ngochanges(main-es2015.41e78b833c373dc8af88.js:8258)
在NgModel.RememberChangeHistory和InvokeOnChangeShake(main-es2015.41e78b833c373dc8af88.js:147472)
在callHook(main-es2015.41e78b833c373dc8af88.js:148484)
在Callhook(main-es2015.41e78b833c373dc8af88.js:148451)
at执行单元和检查钩(main-es2015.41e78b833c373dc8af88.js:148402)
我的图像看起来像

我不确定这是否重要,但我在大多数其他尝试过的下拉列表中都遇到了这个错误,据我所知,问题在于[(ngModel)]=“selectedCity”,好像我删除了该语句,我不会得到错误,即使下拉列表仍然不起作用

我非常感谢大家对我的帮助

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)