我正在routing
我angular
的应用程序中实施。我创建了一个moviecomponent,editmoviecomponent。
editmoviecomponent嵌套在moviecomponent中,如下面的文件夹结构所示。
moviecomponent.html 有一个网格,其中有一列包含指向 editmoviecomponent 的 routerlink。我可以在浏览器地址栏中看到似乎正确的链接,但由于某种原因 endmoviecomponent.html 没有被渲染。相反,NotFound 页面被渲染,该页面也在路由中定义。approuting.module 中的路由定义似乎不正确。
电影.component.html
<kendo-grid-column title="Edit" headerClass="kendoGridHeader" class="kendoGridControlCell">
<ng-template kendoGridCellTemplate let-dataItem>
<span data-title="Edit" [hidden]="!dataItem.isVisibleEdit">
<a [routerLink]="['./edit', dataItem.movieId]" routerLinkActive="active"><i class="fa fa-pencil" aria-hidden="true"></i></a>
</span>
</ng-template>
</kendo-grid-column>
电影组件
import {Component, OnInit} from '@angular/core';
import {MovieService} from './movie.service';
import {IMovie} from './movie.interface';
import { GridDataResult, PageChangeEvent } from '@progress/kendo-angular-grid';
import { SortDescriptor, orderBy } from '@progress/kendo-data-query';
import { MRDBGlobalConstants } from '../shared/mrdb.global.constants';
@Component({
moduleId: module.id,
selector: 'app-movie',
templateUrl: './movie.component.html',
styleUrls: ['./movie.component.css'],
providers:[MovieService]
})
编辑movie.component.html
<p>
editmovie works!
</p>
编辑movie.component
import { Component, OnInit } from '@angular/core';
import {Router,ActivatedRoute} from '@angular/router';
@Component({
selector: 'app-editmovie',
moduleId: module.id,
templateUrl: './editmovie.component.html',
styleUrls: ['./editmovie.component.css']
})
export class EditmovieComponent implements OnInit {
public selectMovieId: number = 0;
public sub : any;
constructor(private _route: ActivatedRoute) {
this.sub = this._route.params.subscribe(params => {
this.selectMovieId = + params['id']; // (+) converts string to number
})
}
ngOnInit() {
}
}
审批模块
import {NgModule} from '@angular/core';
import {Routes,RouterModule} from '@angular/router';
import {MovieComponent} from './movie/movie.component';
import {HomeComponent} from '../app/home/home.component';
import {NotFoundComponent} from './not-found/not-found.component';
import {NewmovieComponent} from './movie/new/newmovie.component';
import {EditmovieComponent} from './movie/edit/editmovie.component';
import {ViewmovieComponent} from './movie/view/viewmovie.component';
export const routes: Routes = [
{path: 'movie', component : MovieComponent},
{path : 'new' , component : NewmovieComponent },
{path : 'edit/:id' , component : EditmovieComponent },
{path : 'view/:id' , component : ViewmovieComponent },
{ path: '', redirectTo: 'home', pathMatch: 'full' },
{path : '', component : HomeComponent},
{path: '**', component : NotFoundComponent}
];
@NgModule({
imports: [RouterModule.forRoot(routes,{useHash: true})],
exports: [RouterModule]
})
export class AppRoutingModule{}
有人可以告诉我可能是什么问题吗?