Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angular2项目教程-微型Blog系统3大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
js太多,就会http请求很多
js少,单个文件又太大
这需要设计者权衡
——————————————————
模块和共享模块
共享模块:SharedModule和PostSharedModule

导入到manage和user模块
——————————————————————
模块懒加载
loadChildren点到路径的时候才加载这个模块,异步加载
第三种组件传递参数,路由
<a [routerLink]="['/manage/usertable/edituser',1]"><i class="fa fa-pencil-square-o" aria-hidden="true"></i></a>
manage.routes.ts
{ path: 'usertable/edituser/:userId',component: UserProfileComponent },
接收
constructor(public router: Router,
public activeRoute: ActivatedRoutE) {
}
ngOnInit() {
this.form = this.toFormGroup(this.fields);
this.activeRoute.params.subscribe(
params => { console.log(params) }
);
}
——————————————————————————————————————————
N层嵌套的路由

manage.routes.ts设置路由
children: [
{ path: '',redirectTo:'posttable/page/1',pathMatch:'full'},
{ path: 'posttable/page/:page',component: PostTableComponent },
{ path: 'commenttable/page/:page',component: CommentTableComponent },
{ path: 'usertable/page/:page',component: UserTableComponent },
{ path: 'usertable/edituser/:userId',
{ path: 'usertable/newuser',
{ path: 'sysparam',component: SysParamComponent },
{ path: '**',redirectTo:'posttable/page/1' }
]
—————————————————————————————————————
路由守卫:
做一些安全防护,判断有没有权限进入指定路由
肯定是向后端发送个请求看是否有权限进入这个页面
canActivate: [AuthGuard],
————————————————————————————————
路由两种方式:带#号的hash,restful风格的路径,需要利用h5的PushState,需要服务端适当的配置

大佬总结

以上是大佬教程为你收集整理的angular2项目教程-微型Blog系统3全部内容,希望文章能够帮你解决angular2项目教程-微型Blog系统3所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。