-
Notifications
You must be signed in to change notification settings - Fork 226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
this.appService.titleEventEmitter.emit(item.name); #7
Comments
1.如果要这么做就不需要服务了,直接通过main组件改变title。 |
所以我那样做是有我的考虑的 |
学习了 |
直接改title并不生效呢,然后我改造了一下,引入了platform-browser的Title,才真正改到标题了 |
啥意思? |
component里定义title属性,<title>标签,并没有被修改 |
只要通过service设置值了,都可以用,刷新后一样还在 |
app routes通过loadChildren载入了MainModule,app.module又注入了MainModule,这样可能会重复注册路由额,本来访问/app/home的,现在直接访问/home,你看路由是不是单独载入了home.compontent |
@zimv const appRoutes: Routes = [ |
@myopenresources |
参考前辈的代码学习angular4,在演练过程中感觉一个可以调整的地方:
把每个component中的构造函数constructor的类似代码this.appService.titleEventEmitter.emit("消息框")移除;在treeview-menu.component.ts 中实现:
itemClicked(item: MenuData) {
if (!this.isLeaf(item)) {
item.isExpend = !item.isExpend;
} else {
this.appService.titleEventEmitter.emit(item.name);//新增代码,该行代码放在最后是不起作用的
this.router.navigate([item.url]);
//this.appService.titleEventEmitter.emit(item.name); //代码在此处没有效果,个人猜测navigate类似return,该操作结束当前代码块的生命周期
}
}
The text was updated successfully, but these errors were encountered: