11import { Component , Input , Optional } from '@angular/core' ;
22import { ViewController } from 'ionic-angular' ;
3- import { Http } from '@ramonornela/http ' ;
3+ import { Subject } from 'rxjs/Subject ' ;
44
55@Component ( {
66 selector : 'loading' ,
@@ -66,7 +66,7 @@ export class StateEmpty {
6666 selector : 'error' ,
6767 template : `
6868 <div *ngIf="enabled">
69- <span class="msg-exception">{{msgException }}</span>
69+ <span class="msg-exception">{{messageException }}</span>
7070 <button ion-button (click)="retryRequest()">
7171 <span>
7272 <ng-content></ng-content>
@@ -78,34 +78,22 @@ export class StateEmpty {
7878export class StateError {
7979 enabled : boolean = false ;
8080
81- private id : string ;
82-
83- private msgException ;
84-
8581 @Input ( ) messageRetry : string = 'Tentar novamente' ;
8682
8783 @Input ( ) messageCallback : Function ;
8884
8985 @Input ( ) error : any ;
9086
91- constructor ( private http : Http ) { }
87+ @ Input ( ) messageException : string ;
9288
93- @Input ( )
94- set messageException ( message : string ) {
95- this . msgException = message ;
96- }
97-
98- @Input ( )
99- set idRetry ( id : string ) {
100- this . id = id ;
101- }
89+ retry = new Subject < StateError > ( ) ;
10290
10391 retryRequest ( ) {
104- this . http . retryRequest ( this . id ) ;
92+ this . retry . next ( this ) ;
10593 }
10694
10795 present ( ) {
108- if ( ! this . msgException ) {
96+ if ( ! this . messageException ) {
10997 if ( ! this . error ) {
11098 throw new Error ( 'Error is required!' ) ;
11199 }
@@ -114,7 +102,7 @@ export class StateError {
114102 let messageError = this . messageCallback ;
115103 throw new Error ( `${ messageError } is not function` ) ;
116104 }
117- this . msgException = this . messageCallback . call ( null , this . error ) ;
105+ this . messageException = this . messageCallback . call ( null , this . error ) ;
118106 }
119107
120108 this . enabled = true ;
0 commit comments