Estoy intentado mostrar los objetos de que paso de localStorage al controlador del componente. Sin embargo al pasarlos no me muestra nada en la vista.
Este Seria el comoponente.
import {
Component, OnInit, Input, Output
}
from '@angular/core';
import {
Router
}
from '@angular/router-deprecated';
import {
MdButton
}
from '@angular2-material/button';
import {
Hero
}
from '../shared/services/hero/hero';
import {
Transaction
}
from '../shared/services/transaction/transaction';
import {
TransactionService
}
from '../shared/services/transaction/transactions.service';
import {
HeroService
}
from '../shared/services/hero/hero.service';
import {
HeroDetailComponent
}
from '../hero-detail/hero-detail.component';
import {
QuickCardComponent
}
from '../shared/components/quick-card/quick-card.component';
@
Component({
selector: 'my-heroes',
templateUrl: 'client/heroes/heroes.component.html',
styleUrls: ['client/home-root/home-root.component.css', 'client/heroes/heroes.component.css'],
directives: [QuickCardComponent, HeroDetailComponent, MdButton]
})
export class HeroesComponent implements OnInit {
heroes: Hero[];
selectedHero: Hero;
transactions: Array < Object > ;
transaction: Transaction;
errorMessage: string;
constructor(
private _heroService: HeroService,
private _transactionService: TransactionService,
private _router: Router) {
this.transactions = new Array();
}
ngOnInit() {
this.getTransactions();
}
getTransactions() {
var localData = JSON.parse(localStorage.getItem('transactions'));
this.transaction = localData;
console.log("mostrando el json para la vista:")
console.log(this.transaction);
}
cuando hago el console.log me muestra el array de objetos que tengo perfectamente. Pero a la hora de mostrarlo en la vista no los muestra
Esta seria la vista:
<md-content>
<md-data-table class="shadow2 table-c">
<thead class="header-table">
<th class="md-text-cell header-item">Supplier Name</th>
<th class="md-text-cell header-item sortable">Partner</th>
<th class="md-text-cell header-item">Date Quoted</th>
<th class="md-text-cell header-item">Old Gas Supplier</th>
<th class="md-text-cell header-item">New Gas Supplier</th>
<th class="md-text-cell header-item">Old Electricity Supplier</th>
<th class="md-text-cell header-item">New Electricity Supplier</th>
<th class="md-text-cell header-item">Customer Name</th>
<th class="md-text-cell header-item">Switch Type</th>
</thead>
<tbody>
<tr class="repeat repeat-fade-in" *ngFor="let transaction of transactions">
<td class="md-text-cell cell-item">{{transaction?.new_elect_supplier_name}}</td>
<td class="md-text-cell cell-item">{{transaction?.referrer_branch_name}}</td>
<td class="md-text-cell cell-item">{{transaction?.switch_confirmed_date}}</td>
<td class="md-text-cell cell-item">{{ transaction?.old_gas_supplier_name }}</td>
<td class="md-text-cell cell-item">{{ transaction?.new_gas_supplier_name }}</td>
<td class="md-text-cell cell-item">{{ transaction?.old_elect_supplier_name }}</td>
<td class="md-text-cell cell-item">{{ transaction?.new_elect_supplier_name }}</td>
<td class="md-text-cell cell-item">{{ transaction?.first_name + ' ' + transaction.last_name }}</td>
<td class="md-text-cell cell-item">{{ transaction?.switch_type }}</td>
</tr>
</tbody>
</md-data-table>
</md-content>
alguien me podria ayudar???
this.transaction = localData;
en lugar dethis.transactions = localData;
?