File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55 [src] ="'C:/temp/angular.png' "
66 [aspectRatioMode] ="aspectRatioMode "
77 > </ image >
8- < text [style.font-size.px] ="45 "> Hello, {{ name }}</ text >
9- < checkbox [checked] ="true "> </ checkbox >
10- < checkbox [checked] ="true " [enabled] ="false "> </ checkbox >
11- < button [style.background-color] ="'green' " (clicked) ="setName() ">
12- Green button
13- </ button >
8+
9+ < app-hello [name] ="name "> </ app-hello >
10+
11+ < text > Github name</ text >
1412 < linedit
1513 [text] ="name "
16- [placeholderText] ="'Insert your name ' "
14+ [placeholderText] ="'Insert github username ' "
1715 (textChanged) ="textChanged($event) "
1816 > </ linedit >
17+
18+ <!-- <checkbox [checked]="true"></checkbox>
19+ <checkbox [checked]="true" [enabled]="false"></checkbox>
20+ <button [style.background-color]="'green'" (clicked)="setName()">
21+ Green button
22+ </button>
23+
1924 <progressbar [value]="40" [minimum]="0" [maximum]="100"></progressbar>
2025 <spinbox
2126 [prefix]="'aa'"
2429 [range]="{ minimum: 0, maximum: 50 }"
2530 [value]="20"
2631 >
27- </ spinbox >
28- < app-hello [name] ="'irustm' "> </ app-hello >
32+ </spinbox> -->
2933 </ view >
3034</ window >
Original file line number Diff line number Diff line change @@ -8,7 +8,7 @@ import { AspectRatioMode } from '@nodegui/nodegui';
88 encapsulation : ViewEncapsulation . None
99} )
1010export class AppComponent {
11- public name = 'World! ' ;
11+ public name = 'irustm ' ;
1212 public aspectRatioMode = AspectRatioMode . KeepAspectRatio ;
1313
1414 setName ( ) {
Original file line number Diff line number Diff line change 11< view >
2- < text > {{ userName }}</ text >
2+ < text [style.font-size.px] =" 45 " > Hello, {{ name }}</ text >
33</ view >
Original file line number Diff line number Diff line change @@ -15,20 +15,26 @@ import { Subscription } from 'rxjs';
1515 encapsulation : ViewEncapsulation . None
1616} )
1717export class HelloComponent implements OnInit , OnDestroy {
18- @Input ( ) name ;
18+ @Input ( ) set name ( value ) {
19+ this . getUsername ( value ) ;
20+ }
1921
2022 public userName : string ;
2123
2224 private subscribtion : Subscription ;
2325
2426 constructor ( private github : GithubService ) { }
2527
26- ngOnInit ( ) : void {
27- this . subscribtion = this . github
28- . getUser ( this . name )
29- . subscribe ( ( data : any ) => {
30- this . userName = data . name ;
31- } ) ;
28+ ngOnInit ( ) : void { }
29+
30+ private getUsername ( username : string ) {
31+ if ( this . subscribtion ) {
32+ this . subscribtion . unsubscribe ( ) ;
33+ }
34+
35+ this . subscribtion = this . github . getUser ( username ) . subscribe ( ( data : any ) => {
36+ this . userName = data . name ;
37+ } ) ;
3238 }
3339
3440 ngOnDestroy ( ) : void {
You can’t perform that action at this time.
0 commit comments