Skip to content

Commit 80030c4

Browse files
committed
1 parent 863b52f commit 80030c4

File tree

2 files changed

+19
-13
lines changed

2 files changed

+19
-13
lines changed

src/app/app.component.html

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
<img style="visibility: {{showDog}}"
2-
src="https://www.dropbox.com/s/ugeqlxvawfqwhth/dog_by_roaming_angel.jpeg?raw=1">
3-
4-
<p>
5-
Picture of a dog should appear above when "showDog" variable in the
6-
component is set to: "visible".<br>
7-
<br>
8-
Current value of showDog: {{showDog}}<br>
9-
<a href="https://unsplash.com/photos/LATYeZyw88c">Photo credits</a>
1+
<p *ngIf="show_ngIf">
2+
Display if ngIf is typed in
103
</p>
4+
5+
<img *ngIf="show_dog"
6+
src="https://www.dropbox.com/s/ugeqlxvawfqwhth/dog_by_roaming_angel.jpeg?raw=1">
7+
8+
<br>
9+
<input (keyup)="imageCheck($event)"><br>

src/app/app.component.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
import { Component } from '@angular/core';
22

33
@Component({
4-
selector: 'app-root',
5-
templateUrl: './app.component.html',
6-
styleUrls: ['./app.component.css']
4+
selector: 'app-root',
5+
templateUrl: './app.component.html',
6+
styleUrls: ['./app.component.css']
77
})
88
export class AppComponent {
9-
showDog = 'visible';
9+
show_ngIf = false;
10+
show_dog = false;
11+
imageCheck(event: any) {
12+
let input_string = event.target.value;
13+
14+
this.show_ngIf = /.*ngIf.*/.test(input_string);
15+
this.show_dog = /.*dog.*/.test(input_string);
16+
}
1017
}

0 commit comments

Comments
 (0)