【发布时间】:2018-07-29 07:50:07
【问题描述】:
我想在某些路线上隐藏一个标题
当您在家时,路线旁边没有任何东西,所以www.mywebsite.com 但是当您登录时,路线中总会有app,所以从现在开始的每个页面都会像这样www.mywebsite.com/app/whatever基本上我当路由中有app 时,想隐藏我的标题
我试过这样做..但它似乎没有工作
任何帮助将不胜感激,如果您知道更好的方法,请告诉我!
component.html
<home-header *ngIf="router != '/app'"></home-header>
component.ts
import { Component } from '@angular/core';
import { Router } from '@angular/router';
export class RootComponent {
router: string;
constructor(
private _router: Router
) {
this.router = _router.url;
}
}
编辑
我已经尝试过这样做..
<home-header *ngIf="router.indexOf('app') > -1"></home-header>
那没用
我也尝试过这样做..
export class RootComponent {
router: string;
constructor(
private _router: Router
) {
this._router.events.subscribe(() => this.router = this._router.url );
}
}
【问题讨论】:
标签: javascript angular typescript