Hello,

I'm new to angular and promise/observable and i am trying some basic 
example to understand them. Here is my example:
I have an interface with 2 promise fields:
export interface Credential {
  readonly uname: Promise<string>;
  readonly pwd: Promise<string>;
}

A service with a method that return the instance of the interface above:
@Injectable({
  providedIn: 'root'
})
export class UserService {
  public getCredential(): Credential {
    let _uname = this.secureStore.get("uname");
    let _pwd = this.secureStore.get("pwd");

    return { uname: _uname, pwd: _pwd };
  }
}

A component that call the service to get the credential object:
@Component({
  selector: 'app-home',
  templateUrl: './home.page.html',
  styleUrls: ['./home.page.scss'],
})
export class HomePage implements OnInit {
  credential: Credential;
  constructor(private userService: UserService) { }

  ngOnInit() {
    this.credential = this.userService.getCredential();
  }
}

Finally my template:
{{ credential.uname | async }}

I'm not sure why there is nothing printed on the screen. Is it normal to 
have a promise inside an object like the way i define my interface?

Thai

-- 
You received this message because you are subscribed to the Google Groups 
"Angular and AngularJS discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/angular/73a3ff06-7c87-4bce-9d2d-92e01195ef33%40googlegroups.com.

Reply via email to