user component shows user from USERS array

master
Matt Huntington 9 years ago
parent 5fc17357d6
commit 519e8f6834

@ -1,2 +1,2 @@
<h2>User Component</h2>
Current User Index: {{userIndex}}
Current User: {{user}}

@ -1,5 +1,6 @@
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { USERS } from './users';
@Component({
selector: 'app-user',
@ -7,7 +8,7 @@ import { ActivatedRoute } from '@angular/router';
styleUrls: ['./user.component.css']
})
export class UserComponent implements OnInit {
userIndex: Number;
user: String;
constructor(
private route: ActivatedRoute
@ -15,7 +16,7 @@ export class UserComponent implements OnInit {
ngOnInit() {
this.route.params.forEach(param => {
this.userIndex = param.index;
this.user = USERS[param.index];
})
}

Loading…
Cancel
Save