0
서비스를 만들었습니다. 글로벌 개체/세션 개체에 값을 할당하려고합니다. 유형이 통화 서명이없는 표현식을 호출 할 수 없습니다.
import { Injectable } from '@angular/core';
@Injectable()
export class SessionService implements ISession {
private _session: string = "SomeValue";
constructor() {
}
set session(value) {
this._session = value;
}
get session() {
return this._session
}
}
export interface ISession {
session: Object
}
그때에 값을 할당하려고 그것을
import { Component, Inject } from '@angular/core';
import { Http } from '@angular/http';
import { SessionService } from "../../services/session.service";
import { ISession } from "../../services/session.service";
@Component({
selector: 'survey',
templateUrl: './survey.component.html'
})
export class SurveyComponent {
public surveys: Survey[];
constructor(http: Http, @Inject('BASE_URL') baseUrl: string, private sessionService : SessionService) {
sessionService.session("xxx");
http.get(baseUrl + 'api/survey').subscribe(result => {
this.surveys = result.json() as Survey[];
}, error => console.error(error));
}
}
sessionService.session ("XXX");
오류가 발생합니다. 도와 줘?
'sessionService.session = "xxx"' –