【问题标题】:show the page names dynamically for all pages to index.html将所有页面的页面名称动态显示到 index.html
【发布时间】:2018-11-02 04:10:03
【问题描述】:

在我们的项目中,我们有多个页面。 我想在我的布局视图上显示特定的视图名称。 例如我的路径是http://localhost:64632/admin/index.html#/Subscribe。那么“订阅”名称应该在主视图上。我想要这段代码使用 javascript。 asp.net C# javascript, webapi

【问题讨论】:

    标签: javascript c# html asp.net asp.net-web-api


    【解决方案1】:

    您可以使用javascript获取当前url:

    var x = window.location.href; 
    

    如果你想要'#/'后面的字符串,你可以使用以下

    var x = window.location.href.split('#/')[1];
    

    【讨论】:

    • 您好,感谢您的回复。它工作正常,但仅在页面刷新时加载 x 的值。这是我的索引视图
    • {{pagetitle}}
  • 我的 js 是 var page = window.location.href.split('#/')[1]; $scope.pagetitle = 页面;
  • 当我点击菜单时它应该改变标题名称。但它没有改变。当我刷新整个页面时,只会根据我的需要更改页面标题。我该怎么办?请帮帮我。
  • 代替“window.location.href”使用“$location.absUrl()”。你需要像 '$scope' 一样注入 '$location'
  • 这也和以前一样。 index.js 没有重新加载。无需重新加载,我需要获取更改后的路径。
  • 猜你喜欢
    相关资源
    最近更新 更多
    热门标签