我想在主体中放入活动值0或1.代码我使用此代码,但我无法发送活动状态。仅发送设置参数。
public activatehomeboxp(id: string): Observable<boolean> {
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let urlSearchParams = new URLSearchParams();
urlSearchParams.append('homeboxpackage_id', id);
urlSearchParams.append('token', this.auth.getCurrentUser().token);
let body = urlSearchParams.toString();
return this.http
.post(Api.getUrl(Api.URLS.activatehomeboxp), body, { headers })
.map((response: Response) => {
let res = response.json();
if (res.StatusCode === 0) {
return true;
}
});
}
我想要这样的事情:
urlSearchParams.append('homeboxpackage_id', id);
urlSearchParams.append('active', '1');
urlSearchParams.append('token', this.auth.getCurrentUser().token);
只有在这种情况下我总是发送活动1,我想发送并激活0,而不是在所有情况下1
你能告诉我任何解决方案吗?
谢谢
答案 0 :(得分:0)
你的意思是什么?
public activatehomeboxp(id: string, isActive: boolean): Observable<boolean> {
let headers = new Headers();
headers.append('Content-Type', 'application/x-www-form-urlencoded');
let urlSearchParams = new URLSearchParams();
urlSearchParams.append('homeboxpackage_id', id);
urlSearchParams.append('token', this.auth.getCurrentUser().token);
urlSearchParams.append("active", (+isActive).toString());
let body = urlSearchParams.toString();
return this.http.post(Api.getUrl(Api.URLS.activatehomeboxp), body, {
headers
})
.map((response: Response) => {
let res = response.json();
if (res.StatusCode === 0) {
return true;
}
});
}