Skip to content

Commit f77f3c0

Browse files
angular-common-http-get-example
Angular5 Common Http GET Example
1 parent 35a877b commit f77f3c0

File tree

11 files changed

+162
-0
lines changed

11 files changed

+162
-0
lines changed

.DS_Store

0 Bytes
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { Component } from '@angular/core';
2+
import { Platform } from 'ionic-angular';
3+
import { StatusBar } from '@ionic-native/status-bar';
4+
import { SplashScreen } from '@ionic-native/splash-screen';
5+
6+
import { HomePage } from '../pages/home/home';
7+
@Component({
8+
templateUrl: 'app.html'
9+
})
10+
export class MyApp {
11+
rootPage:any = HomePage;
12+
13+
constructor(platform: Platform, statusBar: StatusBar, splashScreen: SplashScreen) {
14+
platform.ready().then(() => {
15+
// Okay, so the platform is ready and our plugins are available.
16+
// Here you can do any higher level native things you might need.
17+
statusBar.styleDefault();
18+
splashScreen.hide();
19+
});
20+
}
21+
}
22+
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ion-nav [root]="rootPage"></ion-nav>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { UserProvider } from './../providers/user/user';
2+
import { BrowserModule } from '@angular/platform-browser';
3+
import { ErrorHandler, NgModule } from '@angular/core';
4+
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
5+
import { SplashScreen } from '@ionic-native/splash-screen';
6+
import { StatusBar } from '@ionic-native/status-bar';
7+
8+
import { MyApp } from './app.component';
9+
import { HomePage } from '../pages/home/home';
10+
import { UserProvider } from '../providers/user/user';
11+
import { HttpClientModule } from '@angular/common/http';
12+
13+
@NgModule({
14+
declarations: [
15+
MyApp,
16+
HomePage
17+
],
18+
imports: [
19+
BrowserModule,
20+
IonicModule.forRoot(MyApp),
21+
HttpClientModule
22+
],
23+
bootstrap: [IonicApp],
24+
entryComponents: [
25+
MyApp,
26+
HomePage
27+
],
28+
providers: [UserProvider,
29+
StatusBar,
30+
SplashScreen,
31+
{provide: ErrorHandler, useClass: IonicErrorHandler},
32+
UserProvider
33+
]
34+
})
35+
export class AppModule {}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// http://ionicframework.com/docs/theming/
2+
3+
4+
// App Global Sass
5+
// --------------------------------------------------
6+
// Put style rules here that you want to apply globally. These
7+
// styles are for the entire app and not just one component.
8+
// Additionally, this file can be also used as an entry point
9+
// to import other Sass files to be included in the output CSS.
10+
//
11+
// Shared Sass variables, which can be used to adjust Ionic's
12+
// default Sass variables, belong in "theme/variables.scss".
13+
//
14+
// To declare rules for a specific mode, create a child rule
15+
// for the .md, .ios, or .wp mode classes. The mode class is
16+
// automatically applied to the <body> element in the app.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
2+
3+
import { AppModule } from './app.module';
4+
5+
platformBrowserDynamic().bootstrapModule(AppModule);
189 KB
Loading
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<ion-header>
2+
<ion-navbar>
3+
<ion-title>
4+
Ionic Blank
5+
</ion-title>
6+
</ion-navbar>
7+
</ion-header>
8+
9+
<ion-content padding>
10+
11+
<button ion-button (click)="get()">Load Data</button>
12+
13+
<ion-list>
14+
<ion-item *ngFor="let x of users">
15+
<ion-avatar item-start>
16+
<img src="{{x.picture.medium}}">
17+
</ion-avatar>
18+
<h2>{{x.name.title}}.{{x.name.first}}</h2>
19+
<p>{{x.email}}</p>
20+
</ion-item>
21+
</ion-list>
22+
23+
</ion-content>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
page-home {
2+
3+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UserProvider } from './../../providers/user/user';
2+
import { Component } from '@angular/core';
3+
import { NavController } from 'ionic-angular';
4+
5+
@Component({
6+
selector: 'page-home',
7+
templateUrl: 'home.html'
8+
})
9+
export class HomePage {
10+
11+
constructor(public navCtrl: NavController,private userProvider:UserProvider) {
12+
13+
}
14+
users:any;
15+
get()
16+
{
17+
this.userProvider.getRandomData().then(data=>{
18+
this.users=data
19+
});
20+
}
21+
22+
}

0 commit comments

Comments
 (0)