
committed by
Kara Erickson

parent
bd42caf1c7
commit
9b14483824
@ -34,13 +34,13 @@ describe('Favorite Color Component', () => {
|
||||
input.value = 'Red';
|
||||
input.dispatchEvent(event);
|
||||
|
||||
expect(fixture.componentInstance.favoriteColor.value).toEqual('Red');
|
||||
expect(fixture.componentInstance.favoriteColorControl.value).toEqual('Red');
|
||||
});
|
||||
// #enddocregion view-to-model
|
||||
|
||||
// #docregion model-to-view
|
||||
it('should update the value in the control', () => {
|
||||
component.favoriteColor.setValue('Blue');
|
||||
component.favoriteColorControl.setValue('Blue');
|
||||
|
||||
const input = fixture.nativeElement.querySelector('input');
|
||||
|
||||
|
@ -1,19 +1,13 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { FormControl } from '@angular/forms';
|
||||
|
||||
@Component({
|
||||
selector: 'app-reactive-favorite-color',
|
||||
template: `
|
||||
Favorite Color: <input type="text" [formControl]="favoriteColor">
|
||||
Favorite Color: <input type="text" [formControl]="favoriteColorControl">
|
||||
`,
|
||||
styles: []
|
||||
})
|
||||
export class FavoriteColorComponent implements OnInit {
|
||||
favoriteColor = new FormControl('');
|
||||
|
||||
constructor() { }
|
||||
|
||||
ngOnInit() {
|
||||
}
|
||||
|
||||
export class FavoriteColorComponent {
|
||||
favoriteColorControl = new FormControl('');
|
||||
}
|
||||
|
Reference in New Issue
Block a user