2017-11-12 2 views
0

나는 스택 MEAN에 비교적 익숙하고 여전히 배우고 있습니다.평균 스택 문제

내가 어디에서 오류인지 알 수 없습니다.이 부분은 오류가 있습니다.이 부분은에서 나와 있습니다. 아마 내 경로가 내가 얻을 수 없기 때문에 옳지 않아, 내가 그것을이다 오류의 종류를 모르는 :

import { ApplicationService } from './../../services/applicationService/application.service'; 
import { Component, OnInit } from '@angular/core'; 

@Component({ 
    selector: "cc-search", 
    templateUrl: "./search.component.html", 
    styleUrls: ["./search.component.css"] 
}) 
export class SearchComponent implements OnInit { 
    applications = []; 
    constructor(private applicationService: ApplicationService) {} 

    ngOnInit() {} 
    searchApplications(searchData) { 
    this.applicationService 
     .searchApplication(searchData) 
     .subscribe(
     data => this.applications = data, 
     error => console.error(error) 
    ); 
    } 
} 

및 서버 측에서

Type '() => any' is not assignable to type 'any[]'.Property 'push' is missing in type '() => any'.

: 여기 내 오류의 OUPUT입니다 정보. 사전

+0

있다고 가정 : 당신은 명시 적으로 결과의 유형을 지정해야합니까? 어떤 라인 번호. 그것을 참조합니까? –

+0

에 대한 각도는 다음과 같습니다 : data => this.applications = data, – AznYouth

+0

searchApplication 메소드의 정의를 추가합니다. –

답변

0

에서

const getAllApplications =() => { 
    return [...addedApplications, ...initialApplications]; 
}; 

api.get('search/:term/:place?', (req, res) => { 
    const term = req.params.term.toLowerCase().trim(); 
    let place = req.params.place; 
    let applications = getAllApplications().filter(j => (j.description.toLowerCase().includes(term) || j.title.toLowerCase().includes(term))); 
    console.log('test'); 
    if (place) { 
     place = place.toLowerCase().trim(); 
     applications = applications.filter(j => (j.city.toLowerCase().includes(place))); 
    } 
    res.json({ success: true, applications: applications }); 
}); 

덕분에 당신은 당신의 가입의 결과에 대한 유형을 선언하지 않습니다.

this.applicationService 
    .searchApplication(searchData) 
    .subscribe(
     (data: Application[]) => this.applications = data, 
     error => console.error(error) 
     ); 

나는 당신의 모델이 오류가 않습니다 Application

+0

나는 []로 어플리케이션을 선언합니다. – AznYouth

+0

나는 어떤 경우에 당신은 구독에있는 데이터의 유형을 선언해야합니다. 제 생각에는 그것은 어떤 모델의 유형이어야합니다 @AznYouth –