scrimba
Build Your First Angular app
Angular Routing - Linking to Routes with the routerLink Directive
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Angular Routing - Linking to Routes with the routerLink Directive
AboutCommentsNotes
Angular Routing - Linking to Routes with the routerLink Directive
Expand for more info
src
app
orders
orders.component.ts
run
preview
console
import { Component, OnInit } from '@angular/core';
import { Router, ActivatedRoute, Params } from '@angular/router';

import { DataService } from '../core/data.service';
import { ICustomer, IOrder, IOrderItem } from '../shared/interfaces';

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

orders: IOrder[] = [];
customer: ICustomer;

constructor(private dataService: DataService,
private route: ActivatedRoute) { }

ngOnInit() {
let id = +this.route.snapshot.paramMap.get('id');
this.dataService.getOrders(id).subscribe((orders: IOrder[]) => {
this.orders = orders;
});

this.dataService.getCustomer(id).subscribe((customer: ICustomer) => {
this.customer = customer;
});
}

}
Console
"Angular is running in the development mode. Call enableProdMode() to enable the production mode."
,
customers
-7:39