Permalink
Cannot retrieve contributors at this time
Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign up
Find file
Copy path
ergonomics-ng2-vs-react/ng/src/app/agent-selector.component.ts
Find file
Copy path
Fetching contributors…
| import { Component, OnInit } from '@angular/core'; | |
| import { AgentService } from './agent.service'; | |
| @Component({ | |
| selector: 'app-root', | |
| templateUrl: './agent-selector.component.html', | |
| styleUrls: ['./agent-selector.component.css'] | |
| }) | |
| export class AgentSelectorComponent implements OnInit { | |
| agents: Array<string>; | |
| selectedAgent: string; | |
| title = 'Select an agent'; | |
| constructor( | |
| private agentService: AgentService, | |
| ) { } | |
| // *cannot* be done in the constructor because the spy has to happen after instantiation | |
| ngOnInit() { | |
| this.agents = this.agentService.getAgents(); | |
| } | |
| handleClick(agentIndex: number) { | |
| console.log('click!'); | |
| const agentName = this.agents[agentIndex]; | |
| this.selectedAgent = agentName; | |
| this.title = `You selected agent: ${agentName}`; | |
| } | |
| } |