Ich muss anmelden und ich brauche Option auswählen. Kann ich jemandem helfen, wo ich Fehler mache? Es ist mein CodeWählen Sie in Angular2
@Component({
moduleId: module.id,
selector: 'tenants',
template:`<select name="repeatSelect" id="repeatSelect" [(ngModel)]="model.tenant">
<option *ngFor="let tenant of tenants" value="{{tenant.abbr}}">{{tenant.name}}</option>
</select>`
})
export class TenantComponent implements OnInit {
model: any = {};
loading = false;
error = '';
public tenants: Tenant[];
constructor(
private tenantService: TenantService) { }
setTenant(){
//if you're on older versions of ES, use for-in instead
var tenant = this.tenants.find(t => t.name);
if(tenant) { this.model.tenant = tenant; }
}
ngOnInit() {
this.loading = true;
this.tenantService.tenants()
.subscribe((result : Tenant[]) => {
this.tenants = result;
});
}
}
und dann füge ich in Log-Vorlage.
Wenn ich eine der Optionen wähle. In HTML der Seite ist
nachdem ich Option ausgewählt und Anfrage für Login gesendet. Es funktioniert nicht
Dank
Objektwerte zu verwenden, sollten Sie lieber verwenden: '[Wert] = "tenant.abbr"' statt 'value =“ {{pentent.abbr}} "' – Maxime
Das sollte egal sein, wenn 'tenant.abbr' ein Zeichenfolgenwert ist. –