在Angular5问题中的ng-select:ERROR TypeError:Object(…)不是
发布时间:2020-12-17 07:19:13 所属栏目:安全 来源:网络整理
导读:我在我的项目angular5中使用ng-select 2.0.0,如 this link所示 ,我可以从api休息弹簧启动得到结果,但我正在解决一个问题我得到这个错误,而我点击ng-select: ERROR TypeError: Object(...) is not a functionat NgDropdownPanelComponent.ngOnInit (ng-selec
我在我的项目angular5中使用ng-select 2.0.0,如
this link所示
,我可以从api休息弹簧启动得到结果,但我正在解决一个问题我得到这个错误,而我点击ng-select: ERROR TypeError: Object(...) is not a function at NgDropdownPanelComponent.ngOnInit (ng-select.js:1450) at checkAndUpdateDirectiveInline (core.js:12352) at checkAndUpdateNodeInline (core.js:13876) 而且我也不能选择我想要的信息(在这种情况下属性’nom’),就像ng select被阻止或者像这样的东西. 这是我的project.component.html代码 <ng-select *ngIf="_listClients" [items]="listClient" bindLabel ="nom" bindValue ="id" [(ngModel)]="selectedPersonId"> </ng-select> <p> Selected city ID: {{selectedPersonId | json}} </p> 这是文件project.component.ts import {Component,OnInit,ViewChild} from '@angular/core'; import {ActivatedRoute,Router} from '@angular/router'; import {ProjetService} from '../../../../../service/projet.service'; import {Projet} from '../../Models/Projet'; import { ModalDirective } from 'ngx-bootstrap/modal'; import 'rxjs/add/operator/map'; import {ClientService} from '../../../../../service/client.service'; @Component({ selector: 'app-projects',templateUrl: './projects.component.html',styleUrls: ['./projects.component.scss'] }) export class ProjectsComponent implements OnInit { selectedPersonId:number = null; _listClients :any; constructor(private router:Router,private projetSevice:ProjetService,private clientServ:ClientService,private route: ActivatedRoute) { } ngOnInit() { this.clientList(); } get listClient() { return this._listClients ? this._listClients.map(item => { return {id: item.id,prenom : item.prenom,nom : item.nom} }) : []; } clientList(){ this.clientServ.getListClients() .subscribe((data:any)=>{ this._listClients=data; },err=>{ console.log('this is error '); }) } } 有帮助吗?
(只需复制粘贴我的评论中的答案即可结束问题)
我认为,ng-select v2.0.0有这个问题.我在GitHub回购中找到了2个问题请求. 解决方法: 尝试将版本降级到v1.4.1. npm uninstall @ng-select/ng-select npm i -s @ng-select/ng-select@1.4.1 编辑:(25.05.18) 有问题是从Rxjs 6.0中断更改.如果您正在使用Angular v5 install ng-select v1.x或使用rxjs-compat安装ng-select v2.0. npm i -s @ng-select/ng-select@1.x //or npm i -s @ng-select/ng-select@latest rxjs-compat (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |