PDA

View Full Version : Type 'number' is not assignable to type 'String'



mangfpt
05-27-2018, 02:24 AM
ERROR in src/app/components/add-item/add-item.component.ts(27,7): error TS2322: Type 'number' is not assignable to type 'String'.
src/app/components/items/items.component.ts(29,5): error TS2322: Type 'true' is not assignable to type 'false'.



export class AddItemComponent implements OnInit {
item: Item = {
title: '',
description: '',
date: ''
};

constructor(private itemService: ItemService) { }

ngOnInit() {
}

onSubmit() {
if (this.item.title !== '' && this.item.description !== '') {
this.itemService.addItem(this.item);
this.item.title = '';
this.item.description = '';
this.item.date = new Date().getTime();
}
}

}