Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Store component ---
- export class StoreComponent implements OnInit {
- private items: ItemComponent[] = ItemService.get_items();
- constructor(itemService: ItemService) {}
- }
- --- Item component ---
- export class ItemComponent implements OnInit {
- constructor(private _name: string, private _unitPrice: number, private
- _description?:string, private _image?:string) { }
- ngOnInit() {
- }
- get name(){return this._name;}
- get unitPrice(){return this._unitPrice}
- get description(){return this._description;}
- get image(){return this._image;}
- }
- --- store component html (worked) ---
- <div id="items">
- <th>Name</th>
- <th>unitPrice</th>
- <th>description</th>
- <tr *ngFor='let item of items'>
- <td>{{item.name}}</td>
- <td>{{item.unitPrice}}</td>
- <td>{{item.description}}</td>
- </tr>
- </div>
- --- New Store component html (doesn't work) ---
- <div id="items">
- <th>Name</th>
- <th>unitPrice</th>
- <th>description</th>
- <app-item *ngFor='let item of items'></app-item>
- </tr>
- </div>
- --- New Item component html (doesn't show) ---
- <tr>
- <td>{{name}}</td>
- <td>{{unitPrice}}</td>
- <td>{{description}}</td>
- </tr>
- --- After I edited the html code, I get following error: ---
- ERROR NullInjectorError: StaticInjectorError(AppModule)[ItemComponent ->
- String]:
- StaticInjectorError(Platform: core)[ItemComponent -> String]:
- NullInjectorError: No provider for String!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement