mercredi 25 juillet 2018

error TS1005: ',' expected, failing to compile angular 6 project

whenever i compile, i get this error msg

ERROR in src/app/form/form.component.ts(22,39): error TS1005: ',' expected.

here is the entire code where the error points at:

import { Component, OnInit } from '@angular/core';
import { CommService } from '../services/comm.service';

@Component({
  selector: 'app-form',
  templateUrl: './form.component.html',
  styleUrls: ['./form.component.css']
})
export class FormComponent implements OnInit {


  user = {
    Doctor: '',
    Patient: '',
    Type: '',
    Diagnosis: ''
  };

  constructor(private CommService: CommService) { }

  ngOnInit() {
    this.CommService.setData(this.user);

  }

}

the above code is a simple form, it takes input (user={}) and passes it to a service (CommService.setData)

here is the CommService code:

import { Injectable } from '@angular/core';
import { Observable, of, Subject } from 'rxjs';
import { FormComponent } from '../form/form.component';

@Injectable()
export class CommService {

  getData$: Observable<any>;
  private getDataSubject = new Subject<string>();


  users = {
    Doctor: '',
    Patient: '',
    Type: '',
    Diagnosis: ''
  };

  constructor() { }

  setData (data: any[]) {
    this.users = data;
  }

  getData() {
    return this.users;
  }
}

i am quite a beginner so i bet my mistake is simple, if u can help me i would be grateful




Aucun commentaire:

Enregistrer un commentaire