Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – Angular2 $location.search()等价物(设置查询参数)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的Web应用程序有多个过滤器,应该在当前的Url中表示,以便用户可以简单地复制/书签当前页面便以后将其恢复.

在angular1中,我使用$LOCATIOn.search(name,value)来简单地在变化时设置seach参数.现在我想在angular2中得到类似的东西.

还是错了?

解决方法

我认为你必须在Angular2中使用路由器.代码例:

import {Component} from 'angular2/core';
import {RouteConfig,ROUTER_DIRECTIVES} from 'angular2/router';
import {ProfileComponent} from './profile.component';

@Component({
    SELEctor: 'my-app',template: `
    <router-outlet></router-outlet>
    `,directives: [ROUTER_DIRECTIVES]
})

@RouteConfig([
  {path: '/profile/:id',name: 'Profile',component: ProfileComponent}
])

export class AppComponent {
}

您可以在Angular2 doc:router doc中找到更多详细信息

大佬总结

以上是大佬教程为你收集整理的angularjs – Angular2 $location.search()等价物(设置查询参数)全部内容,希望文章能够帮你解决angularjs – Angular2 $location.search()等价物(设置查询参数)所遇到的程序开发问题。

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

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