This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule, Component } from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { RouterModule, Routes, Route } from '@angular/router'; | |
import { ItemsComponent } from './items/items.component'; | |
import { FavouritesComponent } from './favourites/favourites.component'; | |
import { ItemDetailsComponent } from './item-details/item-details.component'; | |
const routes: Routes = [ | |
{path: 'items', component: ItemsComponent}, | |
{path: 'favourites', component: FavouritesComponent}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Injectable } from '@angular/core'; | |
import { ITEMS } from './demo_items'; | |
import { Item } from './item'; | |
import { Observable, of } from 'rxjs'; | |
import { TransactionsService } from './transactions.service'; | |
@Injectable({ | |
// at the root level, Angular creates a single, shared instance | |
// of ItemService and injects into any class that asks for it. | |
providedIn: 'root' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, Input } from '@angular/core'; | |
import { Item } from '../item'; | |
import { ItemsComponent } from '../items/items.component'; | |
import { ActivatedRoute } from '@angular/router'; | |
import { Location } from '@angular/common'; | |
import { ItemService } from '../item.service'; | |
@Component({ | |
selector: 'app-item-details', | |
templateUrl: './item-details.component.html', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- displays the details --> | |
<div *ngIf='item'> | |
<h3>Details</h3> | |
<label>This is a </label>{{item.name}}<br> | |
<label>Its value is </label>{{item.value}}<br> | |
<label>{{item.info}}</label> | |
</div> | |
<div> | |
<button (click)="goBack()">back</button> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div> | |
<h3>Favourite Items</h3> | |
<div class="grid grid-pad"> | |
<a *ngFor="let item of items" class="col-1-4" | |
routerLink="/details/{{item.id}}"> | |
<div class="module item"> | |
<h4>{{item.name}}</h4> | |
</div> | |
</a> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="items"> | |
<li *ngFor='let item of items'> | |
<a routerLink="/details/{{item.id}}"> | |
<span class="badge">{{item.id}}</span> | |
{{item.name | uppercase}} | |
<span class="value">{{item.value}}</span> | |
</a> | |
</li> | |
</ul> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule, Component } from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { RouterModule, Routes, Route } from '@angular/router'; | |
import { ItemsComponent } from './items/items.component'; | |
import { FavouritesComponent } from './favourites/favourites.component'; | |
const routes: Routes = [ | |
{path: 'items', component: ItemsComponent}, | |
{path: 'favourites', component: FavouritesComponent}, | |
{path: '', redirectTo: '/favourites', pathMatch: 'full'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit } from '@angular/core'; | |
import { ItemService } from '../item.service'; | |
import { Item } from '../item'; | |
@Component({ | |
selector: 'app-favourites', | |
templateUrl: './favourites.component.html', | |
styleUrls: ['./favourites.component.css'] | |
}) | |
export class FavouritesComponent implements OnInit { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h3>Favourite Items</h3> | |
<div class="grid grid-pad"> | |
<a *ngFor="let item of items" class="col-1-4"> | |
<div class="module item"> | |
<h4>{{item.name}}</h4> | |
</div> | |
</a> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { NgModule } from '@angular/core'; | |
import { CommonModule } from '@angular/common'; | |
import { RouterModule, Routes, Route } from '@angular/router'; | |
import { ItemsComponent } from './items/items.component'; | |
const routes: Routes = [{ | |
path: 'items', | |
component: ItemsComponent | |
}]; | |
@NgModule({ |
NewerOlder