Ich versuche eine SegmentedBar zu verwenden, um zwei Arten von Formularen zu visualisieren, die sich in einer anderen Komponente befinden. Wenn ich das Teil mit dem Routing zu den Komponenten entferne, funktioniert alles einwandfrei und die Leiste selbst visualisiert, aber mit dem Routing-Teil sogar die Leiste visualisiert nicht und ist nur leer.Nativescript + Angular Segmentierter Balken kann nicht zu anderen Komponenten weitergeleitet werden?
Eine der Komponenten, die andere ist ähnlich:
<ScrollView>
<StackLayout>
<TextField [text]="first_name" hint="First Name" class="purplish label-marg"></TextField>
<TextField [text]="last_name" hint="Last Name" class="purplish label-marg"></TextField>
<TextField [text]="email" hint="Email" class="purplish label-marg"></TextField>
<TextField [text]="company_name" hint="Company name" class="purplish label-marg"></TextField>
<TextField [text]="company_position" hint="Position in company" class="purplish label-marg"></TextField>
<Label text="Company size" class="purpish label-marg font-weight-bold"></Label>
<ListPicker [items]="sizes"
[text]="company_size" class="p-15" ngDefaultControl>
</ListPicker>
<TextField [text]="company_resume" textWrap="true" hint="Company resume" class="purplish label-marg"></TextField>
<TextField [text]="year_of_creation" hint="Year of creation of the company" class="purplish label-marg"></TextField>
<Label text="Branch of the company" class="purpish label-marg font-weight-bold"></Label>
<ListPicker [items]="branches"
[text]="branch_company" class="p-15" ngDefaultControl>
</ListPicker>
<Label text="Country" class="purpish label-marg font-weight-bold"></Label>
<ListPicker [items]="countries" [text]="country" class="p-15" ngDefaultControl>
</ListPicker>
<TextField [text]="city" hint="City" class="purplish label-marg"></TextField>
<Label text="You can add job opening in your profile" class="purpish" margin-left="20px"></Label>
</StackLayout>
</ScrollView>
Die SegmentedBar Komponente xml/html:
<basictoolbar></basictoolbar>
<StackLayout>
<SegmentedBar #sb [items]="navItems" selectedIndex="0" (selectedIndexChange)="navigate(sb.selectedIndex)">
</SegmentedBar>
<router-outlet></router-outlet>
</StackLayout>
und die TS:
import { Component} from '@angular/core';
import { SegmentedBar, SegmentedBarItem } from "ui/segmented-bar";
import { Router } from '@angular/router';
import {ChangeDetectorRef,ApplicationRef} from '@angular/core';
@Component({
selector: 'cvformpage',
templateUrl: './components/cvformpage/cvformpage.component.html'
})
export class CvformpageComponent {
public navItems: Array<SegmentedBarItem>;
public constructor(private router: Router, private _applicationRef: ApplicationRef,private ref:ChangeDetectorRef) {
this.navItems = [];
this.navItems.push(this.createSegmentedBarItem("Employer Form"));
this.navItems.push(this.createSegmentedBarItem("Employee Form"));
}
private createSegmentedBarItem(title: string): SegmentedBarItem {
let item: SegmentedBarItem = new SegmentedBarItem();
item.title = title;
return item;
}
public navigate(index: number) {
switch(index) {
case 0:
console.log("I am here");
this.router.navigate(["/employer-form"]);
break;
case 1:
this.router.navigate(["/employee-form"]);
break;
}
}
}
ich es mit Konsole versucht log und es kommt in den Schalter und in den richtigen Fall, aber etwas ist mit dem Routing versaut. Ich danke Ihnen im Voraus Jungs, wenn mir jemand auf dem richtigen Weg helfen kann.