我想在Angle 7应用中使用fp = open("animals.txt","r");
struct animal *animal = malloc(sizeof(sturct animal)*3);
int i = 0;
if(fp != NULL) {
while(i < 3) {
fscanf(fp,"%s %d %d %d %s",
animal[i].animal_Type,
animal[i].age,
animal[i].numberOfLegs,
animal[i].walksPerDay,
animal[i].favoriteFood); // need to be able to enter the string of food into here
i++
}
。
app.routingts.ts
routerLink
管理html
const routes: Routes = [
{
path: '',
component: AdminComponent,
children: [
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: 'drivers', loadChildren: './drivers/drivers.module#DriversModule' }
]
}
];
仪表板html
<app-nav></app-nav>
<router-outlet></router-outlet>
来自导航组件的HTML
<app-nav></app-nav>
<router-outlet></router-outlet>
错误
<a class="nav-link" [routerLink]="['/drivers']">Drivers<span class="sr-only">
答案 0 :(得分:2)
您需要具有这样的路由器配置
const routes: Routes = [
{
path: 'admin',
component: AdminComponent,
children: [
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: 'drivers', loadChildren: './drivers/drivers.module#DriversModule' }
]
},
{
path: '',
redirectTo: 'admin',
pathMatch: 'full'
}
];
模板:
<a class="nav-link" [routerLink]="['admin/drivers']">Drivers<span class="sr-only">
答案 1 :(得分:1)
尝试
管理
const routes: Routes = [
{
path: '',
component: AdminComponent,
children: [
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: 'drivers', loadChildren: './drivers/drivers.module#DriversModule' },
]
}
];
HTML
<a class="nav-link" [routerLink]="['drivers']">Drivers<span class="sr-only">
admin.component.html
<app-nav></app-nav>
<router-outlet></router-outlet>
应用路由
{ path: 'admin' , loadChildren:'./admin/admin.module#AdminModule'},
答案 2 :(得分:1)
如果您尝试获取如下网址:localhost:4200/admin/drivers
然后您的路径应如下所示:
const routes: Routes = [
{
path: 'admin',
component: AdminComponent,
children: [
{ path: 'dashboard', loadChildren: './dashboard/dashboard.module#DashboardModule' },
{ path: 'drivers', loadChildren: './drivers/drivers.module#DriversModule' }
]
}
];
您的链接应该是这样:
<a class="nav-link" [routerLink]="['/admin/drivers']">Drivers<span class="sr-only">
对于绝对路线或该路线:
<a class="nav-link" [routerLink]="['drivers']">Drivers<span class="sr-only">
相对路径。 (不加斜线)