Skip to content

Commit a10e488

Browse files
Merge with master
1 parent 96ceea7 commit a10e488

File tree

6 files changed

+74
-2
lines changed

6 files changed

+74
-2
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pages/newuser/newuser.html

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<ion-content padding>
2+
<h2>Add User</h2>
3+
<form (ngsubmit)="saveUser()">
4+
<ion-item>
5+
<ion-label>User ID</ion-label>
6+
<ion-input type="text" [(ngmodel)]="user.id" name="id"></ion-input>
7+
</ion-item>
8+
<ion-item>
9+
<ion-label>First Name</ion-label>
10+
<ion-input type="text" [(ngmodel)]="user.first_name" name="first_name"></ion-input>
11+
</ion-item>
12+
<ion-item>
13+
<ion-label>Email</ion-label>
14+
<ion-input type="text" [(ngmodel)]="user.last_name" name="last_name"></ion-input>
15+
</ion-item>
16+
<ion-item>
17+
<ion-label>Email</ion-label>
18+
<ion-input type="email" [(ngmodel)]="user.email" name="email"></ion-input>
19+
</ion-item>
20+
<button ion-button type="submit" block>Add New User</button>
21+
</form>
22+
</ion-content>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { NgModule } from '@angular/core';
2+
import { IonicPageModule } from 'ionic-angular';
3+
import { NewuserPage } from './newuser';
4+
5+
@NgModule({
6+
declarations: [
7+
NewuserPage,
8+
],
9+
imports: [
10+
IonicPageModule.forChild(NewuserPage),
11+
],
12+
})
13+
export class NewuserPageModule {}

src/pages/newuser/newuser.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
page-newuser {
2+
3+
}

src/pages/newuser/newuser.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { Component } from '@angular/core';
2+
import { IonicPage, NavController, NavParams } from 'ionic-angular';
3+
import { RestProvider } from '../../providers/rest/rest';
4+
5+
/**
6+
* Generated class for the NewuserPage page.
7+
*
8+
* See https://ionicframework.com/docs/components/#navigation for more info on
9+
* Ionic pages and navigation.
10+
*/
11+
12+
@IonicPage()
13+
@Component({
14+
selector: 'page-newuser',
15+
templateUrl: 'newuser.html',
16+
})
17+
export class NewuserPage {
18+
user = { id: '', first_name: '', last_name: '', email: ''};
19+
constructor(public navCtrl: NavController, public navParams: NavParams, public restProvider: RestProvider) { }
20+
21+
ionViewDidLoad() {
22+
console.log('ionViewDidLoad NewuserPage');
23+
}
24+
25+
saveUser() {
26+
this.restProvider.saveUser(this.user).then((result) => {
27+
console.log(result);
28+
}, (err) => {
29+
console.log(err);
30+
});
31+
}
32+
33+
34+
}

src/providers/rest/rest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class RestProvider {
2424
});
2525
}
2626

27-
addUser(data) {
27+
saveUser(data) {
2828
return new Promise((resolve, reject) => {
2929
this.http.post(this.apiUrl+'/users', JSON.stringify(data))
3030
.subscribe(res => {

0 commit comments

Comments
 (0)