6 | Welcome to Ionic!
7 |
8 |
9 |
10 |
11 |
12 |
13 | Username
14 |
15 |
16 |
17 |
18 | Password
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | ADD TODO:
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 | {{q}}
48 |
49 |
50 |
51 |
52 |
--------------------------------------------------------------------------------
/app/pages/page1/page1.js:
--------------------------------------------------------------------------------
1 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5 | return c > 3 && r && Object.defineProperty(target, key, r), r;
6 | };
7 | var __metadata = (this && this.__metadata) || function (k, v) {
8 | if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9 | };
10 | var ionic_angular_1 = require('ionic-angular');
11 | require('rxjs/Rx');
12 | var backandService_1 = require('../../services/backandService');
13 | var Page1 = (function () {
14 | function Page1(backandService) {
15 | this.backandService = backandService;
16 | this.name = 'World';
17 | this.quoteOfTheDay = [];
18 | this.username = 'test@angular2.com';
19 | this.password = 'angular2';
20 | this.auth_type = "N/A";
21 | this.is_auth_error = "";
22 | }
23 | Page1.prototype.getAuthTokenSimple = function () {
24 | var _this = this;
25 | this.auth_type = 'Token';
26 | var $obs = this.backandService.getAuthTokenSimple(this.username, this.password);
27 | $obs.subscribe(function (data) {
28 | _this.auth_status = 'OK';
29 | _this.is_auth_error = false;
30 | }, function (err) {
31 | var errorMessage = _this.extractErrorMessage(err);
32 | _this.auth_status = "Error: " + errorMessage;
33 | _this.is_auth_error = true;
34 | _this.logError(err);
35 | }, function () { return console.log('Finish Auth'); });
36 | };
37 | Page1.prototype.useAnoymousAuth = function () {
38 | this.backandService.useAnoymousAuth();
39 | this.is_auth_error = false;
40 | this.auth_type = 'Anonymous';
41 | };
42 | Page1.prototype.postItem = function () {
43 | var _this = this;
44 | this.backandService.postItem(this.name).subscribe(function (data) {
45 | // add to begin of array
46 | _this.quoteOfTheDay.unshift(data.description);
47 | console.log(_this.quoteOfTheDay);
48 | }, function (err) { return _this.logError(err); }, function () { return console.log('OK'); });
49 | ;
50 | };
51 | Page1.prototype.getQuote = function () {
52 | var _this = this;
53 | this.backandService.getQuote()
54 | .subscribe(function (data) {
55 | console.log("subscribe", data);
56 | _this.quoteOfTheDay = data;
57 | }, function (err) { return _this.logError(err); }, function () { return console.log('OK'); });
58 | };
59 | Page1.prototype.logError = function (err) {
60 | console.error('Error: ' + err);
61 | };
62 | Page1 = __decorate([
63 | ionic_angular_1.Page({
64 | templateUrl: 'build/pages/page1/page1.html',
65 | providers: [backandService_1.BackandService]
66 | }),
67 | __metadata('design:paramtypes', [backandService_1.BackandService])
68 | ], Page1);
69 | return Page1;
70 | })();
71 | exports.Page1 = Page1;
72 | //bootstrap(HelloApp, [HTTP_BINDINGS]);
73 |
--------------------------------------------------------------------------------
/app/pages/page1/page1.scss:
--------------------------------------------------------------------------------
1 | .page1 {
2 |
3 | }
4 |
--------------------------------------------------------------------------------
/app/pages/page1/page1.ts:
--------------------------------------------------------------------------------
1 | import {Page} from 'ionic-angular';
2 | import {Component} from 'angular2/core';
3 | import {bootstrap} from 'angular2/platform/browser';
4 | import 'rxjs/Rx'
5 | import {Http, Headers, HTTP_BINDINGS} from 'angular2/http'
6 | import {BackandService} from '../../services/backandService'
7 |
8 | @Page({
9 | templateUrl: 'build/pages/page1/page1.html',
10 | providers: [BackandService]
11 | })
12 | export class Page1 {
13 | name:string = 'World';
14 | quoteOfTheDay:string[] = [];
15 | username:string = 'test@angular2.com';
16 | password:string = 'angular2';
17 | auth_type:string = "N/A";
18 | is_auth_error:string = "";
19 |
20 | constructor(public backandService:BackandService) {
21 | }
22 |
23 |
24 | public getAuthTokenSimple() {
25 | this.auth_type = 'Token';
26 | var $obs = this.backandService.getAuthTokenSimple(this.username, this.password);
27 | $obs.subscribe(
28 | data => {
29 | this.auth_status = 'OK';
30 | this.is_auth_error = false;
31 |
32 | },
33 | err => {
34 | var errorMessage = this.extractErrorMessage(err);
35 |
36 | this.auth_status = `Error: ${errorMessage}`;
37 | this.is_auth_error = true;
38 | this.logError(err)
39 | },
40 | () => console.log('Finish Auth'));
41 | }
42 |
43 | private useAnoymousAuth() {
44 | this.backandService.useAnoymousAuth();
45 | this.is_auth_error = false;
46 | this.auth_type = 'Anonymous';
47 | }
48 |
49 | public postItem() {
50 | this.backandService.postItem(this.name).subscribe(
51 | data => {
52 | // add to begin of array
53 | this.quoteOfTheDay.unshift(data.description);
54 | console.log(this.quoteOfTheDay);
55 | },
56 | err => this.logError(err),
57 | () => console.log('OK')
58 | );;
59 | }
60 |
61 | public getQuote() {
62 | this.backandService.getQuote()
63 | .subscribe(
64 | data => {
65 | console.log("subscribe", data);
66 | this.quoteOfTheDay = data;
67 | },
68 | err => this.logError(err),
69 | () => console.log('OK')
70 | );
71 | }
72 |
73 | logError(err) {
74 | console.error('Error: ' + err);
75 | }
76 | }
77 |
78 | //bootstrap(HelloApp, [HTTP_BINDINGS]);
--------------------------------------------------------------------------------
/app/pages/page2/page2.html:
--------------------------------------------------------------------------------
1 |
2 |