应用程序组件angular2中的访问参数值
我正在使用appcomponent中的下拉列表。当用户更改下拉列表时,它会在routeroutlet中加载页面。当我刷新时,路由器中的页面被加载,但下拉菜单未被选中。如何在appcomponent中设置下拉列表值应用程序组件angular2中的访问参数值,angular,Angular,我正在使用appcomponent中的下拉列表。当用户更改下拉列表时,它会在routeroutlet中加载页面。当我刷新时,路由器中的页面被加载,但下拉菜单未被选中。如何在appcomponent中设置下拉列表值 import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'contacts-detail', ... }) export class ContactsDetailComponent {
import { ActivatedRoute } from '@angular/router';
@Component({
selector: 'contacts-detail',
...
})
export class ContactsDetailComponent {
constructor(private _route: ActivatedRoute) {
console.log("_route",_route);
}
}
_这条路线对你有帮助
_路由将帮助您您实际上不需要从组件中选择下拉列表。它将根据当前路线自动选择。当当前路由处于活动状态时,路由器链路活动类将添加到锚定标记: 例如:
<div class="sidetab" id="tab1-tab">
<a [routerLink]="['Profile','ProfileOverview']">
<span class="innerSpan"> Overview </span>
</a>
</div>
<div class="sidetab" id="tab2-tab">
<a [routerLink]="['Profile','ProfileActivity']">
<span class="innerSpan"> Activity </span>
</a>
</div>
// Css goes as
.router-link-active .innerSpan {
color: black;
font-weight: bold;
}
概述
活动
//Css就像
.router链接处于活动状态。innerSpan{
颜色:黑色;
字体大小:粗体;
}
您实际上不需要从组件中选择下拉列表。它将根据当前路线自动选择。当当前路由处于活动状态时,路由器链路活动类将添加到锚定标记:
例如:
<div class="sidetab" id="tab1-tab">
<a [routerLink]="['Profile','ProfileOverview']">
<span class="innerSpan"> Overview </span>
</a>
</div>
<div class="sidetab" id="tab2-tab">
<a [routerLink]="['Profile','ProfileActivity']">
<span class="innerSpan"> Activity </span>
</a>
</div>
// Css goes as
.router-link-active .innerSpan {
color: black;
font-weight: bold;
}
概述
活动
//Css就像
.router链接处于活动状态。innerSpan{
颜色:黑色;
字体大小:粗体;
}
刷新后,您将无法获得值因为我无法访问appcomponent.html中激活的路由参数我有RouteOutlet。更改下拉列表时,我正在传递id并调用router.navigate以在routeroutlet中加载页面。刷新后,您将无法获得值。我无法访问appcomponent.html中激活的路由参数我有routeroutlet。更改下拉列表时,我传递id并调用router.navigate到routeroutlet中的加载页面。我可以使用productcomponent中的_route访问productid。但是,我无法访问appcomponent.console.log(“this.\u-route”,this.\u-route.snapshot.url.toString())中的productid;我可以使用productcomponent中的_路径访问productid。但是,我无法访问appcomponent.console.log(“this.\u-route”,this.\u-route.snapshot.url.toString())中的productid;