Skip to content

Commit e9255cf

Browse files
committed
updates
1 parent 62a5c68 commit e9255cf

16 files changed

+3460
-110
lines changed

demo-angular/src/app/app.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { Async } from 'nativescript-async';
2-
console.log(new Async().message);
31
import { Component } from "@angular/core";
42

53
@Component({

demo-angular/src/app/app.module.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
1-
import { NgModule, NO_ERRORS_SCHEMA } from "@angular/core";
2-
import { NativeScriptModule } from "nativescript-angular/nativescript.module";
3-
4-
import { AppRoutingModule } from "./app-routing.module";
5-
import { AppComponent } from "./app.component";
1+
import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
2+
import { NativeScriptModule } from 'nativescript-angular/nativescript.module';
3+
import { NativeScriptAsyncModule } from 'nativescript-async/angular';
4+
import { AppRoutingModule } from './app-routing.module';
5+
import { AppComponent } from './app.component';
6+
import { NativeScriptHttpClientModule } from 'nativescript-angular/http-client';
67

78
@NgModule({
89
bootstrap: [
910
AppComponent
1011
],
1112
imports: [
1213
NativeScriptModule,
14+
NativeScriptHttpClientModule,
15+
NativeScriptAsyncModule,
1316
AppRoutingModule
1417
],
1518
declarations: [
@@ -19,4 +22,5 @@ import { AppComponent } from "./app.component";
1922
NO_ERRORS_SCHEMA
2023
]
2124
})
22-
export class AppModule { }
25+
export class AppModule {
26+
}
Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,45 @@
11
<ActionBar class="action-bar">
2-
<Label class="action-bar-title" text="Home"></Label>
2+
<Label class="action-bar-title" text="Home"></Label>
33
</ActionBar>
44

5-
<GridLayout class="page">
6-
<!-- Add your page content here -->
7-
</GridLayout>
5+
<StackLayout class="page">
6+
<Button (tap)="getRandomUser()" text="Get Random"></Button>
7+
<Label text="Requests Count"></Label>
8+
<TextField #userCount text="1"></TextField>
9+
<Label text="Users Results Count"></Label>
10+
<TextField #userResults text="10"></TextField>
11+
<Button (tap)="getRandomUsers(userCount.text, userResults.text)" text="Get RandomUsers"></Button>
12+
<Button (tap)="makeRequest()" text="Make Request"></Button>
13+
<Button (tap)="makeXhr()" text="Make Xhr Request"></Button>
14+
<Button (tap)="base64Xhr()" text="Upload Image Request"></Button>
15+
<Button (tap)="showNext()" text="showNext"></Button>
16+
<Button (tap)="showPrevious()" text="showPrevious"></Button>
17+
<Image [visibility]="dataService?.currentLoadedImage ? 'visible':'collapse'" height="200"
18+
[src]="dataService?.currentLoadedImage"></Image>
19+
<ListView [items]="dataService.randomUsers" class="list-group" row="2" height="100%">
20+
<ng-template let-item="item">
21+
<GridLayout rows="40, auto, auto, auto" [nsRouterLink]="['/item', item.id]">
22+
<Image height="40" width="40" borderRadius="20" [src]="item?.picture?.thumbnail"></Image>
23+
<Label row="1">
24+
<FormattedString>
25+
<Span text="Name: "></Span>
26+
<Span [text]="item?.name?.title + ' ' + item?.name?.first + ' ' + item?.name?.last | titlecase"></Span>
27+
</FormattedString>
28+
</Label>
29+
<Label row="2">
30+
<FormattedString>
31+
<Span text="DOB: "></Span>
32+
<Span [text]="item?.dob?.date | date:'dd/MM/yyyy' "></Span>
33+
</FormattedString>
34+
</Label>
35+
<Label row="3">
36+
<FormattedString>
37+
<Span text="Address: "></Span>
38+
<Span [text]="item?.location?.street "></Span>
39+
</FormattedString>
40+
</Label>
41+
42+
</GridLayout>
43+
</ng-template>
44+
</ListView>
45+
</StackLayout>
Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,47 @@
1-
import { Component, OnInit } from "@angular/core";
1+
import { Component, OnInit } from '@angular/core';
2+
import { DataService } from '~/app/services/data.service';
23

34
@Component({
4-
selector: "Home",
5+
selector: 'Home',
56
moduleId: module.id,
6-
templateUrl: "./home.component.html"
7+
templateUrl: './home.component.html'
78
})
89
export class HomeComponent implements OnInit {
910

10-
constructor() {
11+
constructor(private dataService: DataService) {
1112
// Use the component constructor to inject providers.
1213
}
1314

1415
ngOnInit(): void {
1516
// Init your component properties here.
1617
}
18+
19+
20+
getRandomUser() {
21+
this.dataService.getRandomUser();
22+
}
23+
24+
getRandomUsers(count: any, users: any) {
25+
this.dataService.getRandomUsers(count, users);
26+
}
27+
28+
makeRequest() {
29+
this.dataService.makeRequest();
30+
}
31+
32+
makeXhr() {
33+
this.dataService.makeXhr();
34+
}
35+
36+
base64Xhr() {
37+
this.dataService.base64Xhr();
38+
}
39+
40+
showNext() {
41+
this.dataService.showNext()
42+
}
43+
44+
showPrevious() {
45+
this.dataService.showPrevious();
46+
}
1747
}

demo-angular/src/app/home/home.module.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { NativeScriptCommonModule } from "nativescript-angular/common";
33

44
import { HomeRoutingModule } from "./home-routing.module";
55
import { HomeComponent } from "./home.component";
6+
import { DataService } from '~/app/services/data.service';
67

78
@NgModule({
89
imports: [
@@ -14,6 +15,9 @@ import { HomeComponent } from "./home.component";
1415
],
1516
schemas: [
1617
NO_ERRORS_SCHEMA
18+
],
19+
providers:[
20+
DataService
1721
]
1822
})
1923
export class HomeModule { }

0 commit comments

Comments
 (0)