File tree Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Expand file tree Collapse file tree 2 files changed +19
-13
lines changed Original file line number Diff line number Diff line change 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
10
3
</ 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 >
Original file line number Diff line number Diff line change 1
1
import { Component } from '@angular/core' ;
2
2
3
3
@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' ]
7
7
} )
8
8
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 = / .* n g I f .* / . test ( input_string ) ;
15
+ this . show_dog = / .* d o g .* / . test ( input_string ) ;
16
+ }
10
17
}
You can’t perform that action at this time.
0 commit comments