url中的routerlink复制路径

时间:2018-07-05 16:31:39

标签: angular

我具有以下路线设置:

@SupportedAnnotationTypes("org.example.EndOfTheCurrentDay")
@SupportedSourceVersion(SourceVersion.RELEASE_8)
public class EndOfDayAnnotationsProcessor extends AbstractProcessor
{

    @Override
    public boolean process(
            Set<? extends TypeElement> annotations,
            RoundEnvironment roundEnv)
    {
        for (Element element : roundEnv.getElementsAnnotatedWith(annotations.iterator().next()))
        {
            if(!element.asType().toString().equals(Date.class.getName())){
                processingEnv.getMessager().printMessage(ERROR,"annotation @EndOfTheCurrentDay can only be applied to java.util.Date!",element);
            }
        }
        return true;
    }

}

];

http://localhost:4200/application页上,我使用以下方法建立了href:

export const appRoutes:Routes = [
{ path: 'application/:id', component: ApplicationEditComponent, resolve: {applicationdropdowns: ApplicationEditResolver}},
{ path: 'application', component: ApplicationListComponent, resolve: {applications: ApplicationListResolver, applicationStatus: ApplicationstatusResolver}},
{ path: '', redirectTo: '/application', pathMatch: 'full'}

当我将鼠标悬停在链接上时,我看到: 本地主机:4200 / application / 1

但是当我单击它时,解析器触发,但是随后我在控制台中看到以下错误:

  

错误:无法匹配任何路由。网址段:   'application / application / 1'

它似乎在路由中添加了一个附加的“应用程序”,仅当我使用解析器时才会发生。

我可以通过转到url手动访问页面,看起来不错。另外,如果我删除了解析器,则来自应用程序页面的链接会正常工作。我的解析器如下:

<a [routerLink]="['/application', application?.applicationSeqid]">click here</a>

该下拉服务应该从2个api调用返回数据,我想将它们都加载到解析器中:

@Injectable()
export class ApplicationEditResolver implements Resolve<any> {
    constructor(private _dropDownService : ApplicationDropdownService) { }

  resolve(){
    return this._dropDownService.getApplicationDropdowns().map(data => {
      let applicationDropdowns = <IApplicationDropdown>{};
      applicationDropdowns.applicationStatuses = data[0];
      applicationDropdowns.applicationTypes = data[1];
      return applicationDropdowns;
    });
  }
}

0 个答案:

没有答案