Hi,
I call this observable metod (it works):

constructor(private Servizio: Services) {
}

ngOnInit() {
    
this.getUtenti();
//this.utente.ute  = this.Utenti[0] ;
//this.utente.azienda = this.Utenti['azienda'];
//this.utente.anno    = this.Utenti['anno'];
}

getUtenti() {
this.Servizio.getUtente()
.subscribe(
Utenti => this.Utenti = Utenti,
error => this.errorMessage = <any>error);

}

If I use the ngFor it works well:
<h2 *ngFor="let utente of Utenti">
   <h2>Operatore: {{utente.utente}}</h2>
   <h2>Azienda:   {{utente.azienda}}</h2>
   <h2>Esercizio: {{utente.anno}}</h2>
</h2>


I would take the individual elements of the array, like this:
this.utente.utente  = this.Utenti[0].utente
 
but I have the error: 
*core.umd.js:3427 EXCEPTION: Cannot read property 'utente' of undefined*
or: *EXCEPTION: Cannot read property '0' of undefined*


Data from Observable is a file.json like this:
{
  "data": [
    { "utente": "UTE", "azienda": "01", "anno": "2016"}
  ]
}


Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to