Guest User

Untitled

a guest
May 11th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. import { Component } from '@angular/core';
  2. import { IonicPage, NavController, NavParams } from 'ionic-angular';
  3. import { NativeStorage } from '@ionic-native/native-storage';
  4. import { EditaccountPage } from '../editaccount/editaccount';
  5. import { AuthServiceProvider } from '../../providers/auth-service/auth-service';
  6. import { Observable } from 'rxjs/Observable';
  7. /**
  8. * Generated class for the MyaccountPage page.
  9. *
  10. * See https://ionicframework.com/docs/components/#navigation for more info on
  11. * Ionic pages and navigation.
  12. */
  13.  
  14. @IonicPage()
  15.  
  16. @Component({
  17. selector: 'page-myaccount',
  18. templateUrl: 'myaccount.html',
  19. })
  20. export class MyaccountPage {
  21.  
  22.  
  23. public myAccountData;
  24. constructor(public navCtrl: NavController, public navParams: NavParams, private nativeStorage: NativeStorage, public authServiceProvider: AuthServiceProvider) {
  25.  
  26. }
  27.  
  28. setmyAccountData(data){
  29. this.myAccountData=this.authServiceProvider.getData("userbyid/40").subscribe( myData => {
  30. this.myAccountData=myData;
  31. });
  32. }
  33. gotoEdit(){
  34. this.navCtrl.push(EditaccountPage);
  35.  
  36. }
  37.  
  38. }
  39.  
  40. import { Injectable } from '@angular/core';
  41. import { HttpClient } from '@angular/common/http';
  42. import 'rxjs/add/operator/toPromise';
  43. import { Observable } from 'rxjs/Observable';
  44. let apiUrl = "http://192.168.1.2/api/v1/"
  45. /*
  46. Generated class for the AuthServiceProvider provider.
  47.  
  48. See https://angular.io/guide/dependency-injection for more info on providers
  49. and Angular DI.
  50. */
  51. @Injectable()
  52. export class AuthServiceProvider {
  53.  
  54. constructor(public http: HttpClient) {
  55. console.log('Hello AuthServiceProvider Provider');
  56. }
  57.  
  58. public async postData(credentials, type): Promise<any> {
  59.  
  60. await this.http.post(apiUrl + type, JSON.stringify(credentials)).toPromise();
  61. }
  62. public getData(type): Observable<any> {
  63.  
  64. return this.http.get(apiUrl + type);
  65.  
  66.  
  67. }
  68.  
  69. }
  70.  
  71. ERROR Error: Uncaught (in promise): TypeError: _co.myAccountData is undefined
  72. View_MyaccountPage_0/<@ng:///AppModule/MyaccountPage.ngfactory.js:128:13
  73. updateRenderer@http://localhost:8100/build/vendor.js:14342:20
  74. checkAndUpdateView@http://localhost:8100/build/vendor.js:13866:5
  75. callViewAction@http://localhost:8100/build/vendor.js:14211:21
  76. execComponentViewsAction@http://localhost:8100/build/vendor.js:14143:13
  77. checkAndUpdateView@http://localhost:8100/build/vendor.js:13867:5
  78. ViewRef_.prototype.detectChanges@http://localhost:8100/build/vendor.js:11653:9
  79. NavControllerBase.prototype._viewAttachToDOM@http://localhost:8100/build/vendor.js:51117:9
  80. Tab.prototype._viewAttachToDOM@http://localhost:8100/build/vendor.js:77128:9
  81. NavControllerBase.prototype._transition@http://localhost:8100/build/vendor.js:51197:13
  82. NavControllerBase.prototype._nextTrns/<@http://localhost:8100/build/vendor.js:50918:40
  83. F</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14974
  84. onInvoke@http://localhost:8100/build/vendor.js:4982:24
  85. F</l</t.prototype.invoke@http://localhost:8100/build/polyfills.js:3:14901
  86. F</c</r.prototype.run@http://localhost:8100/build/polyfills.js:3:10124
  87. f/<@http://localhost:8100/build/polyfills.js:3:20240
  88. F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649
  89. onInvokeTask@http://localhost:8100/build/vendor.js:4973:24
  90. F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562
  91. F</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815
  92. o@http://localhost:8100/build/polyfills.js:3:7887
  93. F</h</e.invokeTask@http://localhost:8100/build/polyfills.js:3:16823
  94. p@http://localhost:8100/build/polyfills.js:2:27646
  95. v@http://localhost:8100/build/polyfills.js:2:27893
  96.  
  97. Stack trace:
  98. c@http://localhost:8100/build/polyfills.js:3:19752
  99. c@http://localhost:8100/build/polyfills.js:3:19461
  100. f/<@http://localhost:8100/build/polyfills.js:3:20233
  101. F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15649
  102. onInvokeTask@http://localhost:8100/build/vendor.js:4973:24
  103. F</l</t.prototype.invokeTask@http://localhost:8100/build/polyfills.js:3:15562
  104. F</c</r.prototype.runTask@http://localhost:8100/build/polyfills.js:3:10815
  105. o@http://localhost:8100/build/polyfills.js:3:7887
  106. F</h</e.invokeTask@http://localhost:8100/build/polyfills.js:3:16823
  107. p@http://localhost:8100/build/polyfills.js:2:27646
  108. v@http://localhost:8100/build/polyfills.js:2:27893
  109. core.js:1350
Add Comment
Please, Sign In to add comment