docs: refactor `HeroDetailComponent` and unit test (#42349)

remove `@Input()` decorator from `hero` property because the component
is designed to get the hero via a service, not an input binding.

add `HTMLElement` type to `HeroDetailComponent` unit test

PR Close #42349
This commit is contained in:
Sam Severance 2021-05-26 10:52:21 -04:00 committed by Zach Arend
parent c110d050f2
commit 74ebdf6fdc
2 changed files with 5 additions and 5 deletions

View File

@ -193,9 +193,9 @@ function heroModuleSetup() {
// #docregion title-case-pipe
it('should convert hero name to Title Case', () => {
// get the name's input and display elements from the DOM
const hostElement = fixture.nativeElement;
const nameInput: HTMLInputElement = hostElement.querySelector('input');
const nameDisplay: HTMLElement = hostElement.querySelector('span');
const hostElement: HTMLElement = fixture.nativeElement;
const nameInput: HTMLInputElement = hostElement.querySelector('input')!;
const nameDisplay: HTMLElement = hostElement.querySelector('span')!;
// simulate user entering a new name into the input box
nameInput.value = 'quick BROWN fOx';

View File

@ -1,6 +1,6 @@
/* tslint:disable:member-ordering */
// #docplaster
import { Component, Input, OnInit } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { Hero } from '../model/hero';
@ -23,7 +23,7 @@ export class HeroDetailComponent implements OnInit {
// #enddocregion ctor
// #enddocregion prototype
@Input() hero!: Hero;
hero!: Hero;
// #docregion ng-on-init
ngOnInit(): void {