【问题标题】:click to remove/Deactivate Auxiliary Route in angular 2单击以删除/停用角度 2 中的辅助路线
【发布时间】:2016-03-25 12:49:04
【问题描述】:

当我点击撰写按钮打开电子邮件模板时(例如,点击撰写邮件时在 gmail 中给出),在单个页面中使用多个模板的辅助路由。

问题是:当点击十字按钮时,如何删除或停用此辅助路线。

app.ts

   @RouteConfig([
    {
     path: '/',
     name: 'OpportunityList',
     component: OpportunityComponent,
     useAsDefault: true
    },
    {
     path: '/detail',
     name: 'Detail',
     component: DetailComponent
    },
    {
     aux: '/mailer', 
     name: 'Mailer', 
     component: MailerComponent
     }
   ])

app.html

    <a [routerLink]="['/', ['Mailer'] ]" >Compose</a>

ma​​iler.component.ts

   export class MailComponent implements OnInit{
      closeEmail(){
          console.log("please suggest me to Deactivate this template")
       }
    }

ma​​iler.component.html

   <div class="header with-bord">
     <h3 class="title">New Message <a (click)="closeEmail()" class="close"><i class="fa fa-times"></i></a></h3>
    </div>

【问题讨论】:

标签: angular angular2-routing angular2-template


【解决方案1】:
this.router.navigate([{ outlets: { aux: null } }]);

【讨论】:

  • 欢迎来到 Stack Overflow!虽然这段代码 sn-p 可以解决问题,但including an explanation 确实有助于提高帖子的质量。请记住,您正在为将来的读者回答问题,而这些人可能不知道您的代码建议的原因。也请尽量不要用解释性的 cmets 挤满你的代码,这会降低代码和解释的可读性!
猜你喜欢
  • 1970-01-01
  • 2017-06-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-04-26
  • 2019-05-17
  • 2018-07-04
  • 1970-01-01
相关资源
最近更新 更多