I am trying an app in MEAN stack. I have created a contact list for add. edit, update,delete operation using MEAN. When I am trying to get all contacts from my Contact model I am getting the below errors in my code.
Kindly my code below.
import { Component, OnInit } from '@angular/core';
import {ContactService} from '../contact.service';
import {Contact} from '../contact';
@Component({
selector: 'app-contacts',
templateUrl: './contacts.component.html',
styleUrls: ['./contacts.component.css'],
providers: [ContactService]
})
export class ContactsComponent implements OnInit {
contacts: Contact[];
contact:Contact;
first_name:string;
last_name:string;
phone:string;
constructor(private contactService: ContactService) { }
ngOnInit() {
this.contactService.getContacts()
.subscribe( contacts->this.contacts = contacts);
}
}
I got the below errors when I run my application
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,28): Expression expected.
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,43): ',' expected.
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,19): Cannot find name 'contacts'. Did you mean the instance member 'this.contacts'?
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,19): Argument of type 'boolean' is not assignable to parameter of type '(value: any) => void'.
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,19): Operator '>' cannot be applied to types 'number' and 'Contact[]'.
ERROR in /var/www/html/contactlist/client/src/app/contacts/contacts.component.ts (22,45): Cannot find name 'contacts'. Did you mean the instance member 'this.contacts'?
ERROR in ./src/app/contacts/contacts.component.ts
Module parse failed: /var/www/html/contactlist/client/node_modules/@ngtools/webpack/src/index.js!/var/www/html/contactlist/client/src/app/contacts/contacts.component.ts Unexpected token (18:35)
You may need an appropriate loader to handle this file type.
| ContactsComponent.prototype.ngOnInit = function () {
| this.contactService.getContacts()
| .subscribe(contacts - > this.contacts, contacts);
| };
| return ContactsComponent;
@ ./src/app/app.module.ts 12:0-66
@ ./src/main.ts
@ multi webpack-dev-server/client?http://localhost:4200 ./src/main.ts
via rsvijay
No comments:
Post a Comment