framadate-responsive/src/app/config.service.ts

38 lines
1010 B
TypeScript
Raw Normal View History

2019-08-10 16:20:59 +02:00
import {Injectable} from '@angular/core';
import {PollConfig} from './config/PollConfig';
import {HttpClient} from "@angular/common/http";
import {environment} from "../environments/environment";
2019-08-10 16:20:59 +02:00
/**
* le service transverse à chaque page qui permet de syncroniser la configuration de sondage souhaitée
*/
@Injectable({
providedIn: 'root'
})
export class ConfigService extends PollConfig {
myEmail: string;
myPolls: any;// list of retrieved polls from the backend api
2019-08-10 16:20:59 +02:00
constructor(public http: HttpClient) {
super();
2019-08-10 16:20:59 +02:00
}
set(key, val) {
this[key] = val;
}
createPoll() {
2019-08-10 16:20:59 +02:00
// todo
console.log('sends the form');
alert('envoi de formulaire pour création de sondage en XHR à faire');
const payload = this;
this.http.post(`${environment.baseApiHref}/poll`, payload)
.subscribe(res => {
console.log('res', res)
},
err => console.error('err', err))
2019-08-10 16:20:59 +02:00
}
}