【问题标题】:How to append search string to URL?如何将搜索字符串附加到 URL?
【发布时间】:2017-10-23 08:49:39
【问题描述】:

我正在用 Angular JS 做一个项目。我有一个 HTML 文件,它有一个链接。该链接将用户带到另一个页面,该页面的状态为我的应用程序的所有组件

现在我想修改那个链接,让它显示一个特定组件的状态,它的名字是“Deployment-manager”。为此,我需要在 URL 中应用搜索字符串。

这是我当前的网址:

http://10.0.1.189:5601/#/dashboard/Default?_g=()&_a=(filters:!(),panels:!((col:7,columns:!
(host,path,message),id:yarn,row:6,size_x:6,size_y:3,sort:!(%27@timestamp%27,desc),
type:search),(col:1,columns:!(host,path,message),id:kafka,row:6,size_x:6,size_y:3,
sort:!(%27@timestamp%27,desc)",type:search),(col:1,columns:!(host,path,message),id:minion,row:9,size_x:12,size_y:3,sort:!(%27@timestamp%27,desc),
type:search),(col:1,id:All-log-types-over-time,row:1,size_x:12,size_y:2,type:visualization),(col:1,columns:!
(host,path,message,source),id:all,row:3,size_x:12,size_y:3,sort:!(%27@timestamp%27,desc),type:search)),
query:(query_string:(analyze_wildcard:!t,query:%27*%27)),title:Default)

如果您仔细查看此链接,您会在该链接的最后一行“查询”字符串。我需要在那里输入特定的组件名称。类似于以下网址:

http://10.0.1.189:5601/#/dashboard/Default?_g=()&_a=(filters:!(),panels:!((col:7,columns:!(host,path,message),id:yarn,row:6,size_x:6,size_y:3,sort:!(%27@timestamp%27,desc),type:search),(col:1,columns:!(host,path,message),id:kafka,row:6,size_x:6,size_y:3,sort:!(%27@timestamp%27,desc),type:search),(col:1,columns:!(host,path,message),id:minion,row:9,size_x:12,size_y:3,sort:!(%27@timestamp%27,desc),type:search),(col:1,id:All-log-types-over-time,row:1,size_x:12,size_y:2,type:visualization),(col:1,columns:!(host,path,message,source),id:all,row:3,size_x:12,size_y:3,sort:!(%27@timestamp%27,desc),type:search)),query:(query_string:(analyze_wildcard:!t,query:deployment-manager)),title:Default)

在上面的 URL 中,我已将特定组件名称(即“Deployment-manager”)放入查询字符串中。如何在 HTML 或 AngularJS 或 Javascript 中附加它。

下面是我的 HTML 代码,里面有链接:

<p>Please follow <a target="_blank" href="{{link}}" class="tooltip-test" data-title="{{link}}" bs-tooltip>this</a> link to fix issues related to {{componentName}}.</p>
"

此链接的 {{link}} 值来自我的 Angular Js 控制器。控制器发送此链接的值仅此http://10.0.1.189:5601 但它会被翻译成我上面提到的一个大 URL。

所以我需要将此查询参数附加到我的 URL 中。我该怎么做?

【问题讨论】:

  • 您必须将此 url 重定向到上面给定的 URL,这些 URL 正在您的应用程序模块文件中检查您为页面重定向代码定义的位置

标签: javascript html angularjs url


【解决方案1】:

您可以使用 $location 服务,$location.url(url).search(search);

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-01-12
    • 2014-04-25
    相关资源
    最近更新 更多