以角度2:400(错误请求)搜索错误

时间:2017-12-06 12:29:52

标签: angular typescript debugging

在项目中,当用户搜索“员工”时,他应该被重定向到搜索“员工”的个人资料页面。

问题出现在组件ProfilesResult:

的ngOnInit方法中
  ngOnInit(): void {
    this.loadItemElementTemplate().takeUntil(this.ngUnsubscribe).subscribe(x => {
        this.itemElement = x;
    });
    this.activatedRoute.params.takeUntil(this.ngUnsubscribe).subscribe(params => {
        let profileId = params['id'];
        if (profileId) {
            this.profileIdQueryParam = profileId;
        }
    });
    setTimeout(() => {
        this.profileIdScroll = this.profileIdQueryParam;
    })
    console.log("Profile results ngOnInit");
}

这是被称为“ngOnInit()”的方法:

  1. `

    private loadItemElementTemplate() {
      return this.dataService.loadActionWidget(this.path).map((data: any) => {
        let itemElement: UiElement = JSON.parse(data.Data.WidgetJson);
        return itemElement;
     });
    }`
    
    
    loadActionWidget(path: string) {
      return this.requests.get(environment.actionWidgetDefinitionUrl + path,      
        this.options, null);
     }
    
     get(url: string, options: RequestOptions, params: any): Observable<any> 
      {
        return this.http.get(url, options)
          .map((res: any) => res.json())
          .catch((error: any) => Observable.throw(error.json()) || 'Server 
           error');
      }
    
    
    
     NgOnInit of profile-result.component.ts 
        ngOnInit(): void {    
       this.loadItemElementTemplate().takeUntil(this.ngUnsubscribe)
        .subscribe(x => {
          this.itemElement = x;
        });
        this.activatedRoute.params.takeUntil(this.ngUnsubscribe)
          .subscribe(params => {
             let profileId = params['id'];
           if (profileId) {
              this.profileIdQueryParam = profileId;
           }
         });
          setTimeout(() => {
             this.profileIdScroll = this.profileIdQueryParam;
          })
           console.log("Profile results ngOnInit");
         }
    
  2. 错误: Error in console

0 个答案:

没有答案