click to remove/Deactivate Auxiliary Route in angular 2

主宰稳场 提交于 2019-12-23 16:31:43

问题


When I do click on compose button to open email template (e.g; as given in gmail when click to compose mail), using Auxiliary Route for multiple template in single page.

Question is : how to remove or Deactivate this Auxiliary Route, when click on cross button.

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>

mailer.component.ts

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

mailer.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>

回答1:


this.router.navigate([{ outlets: { aux: null } }]);


来源:https://stackoverflow.com/questions/36220266/click-to-remove-deactivate-auxiliary-route-in-angular-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!