简体   繁体   English

为单页应用程序 (SPA) 创建链接以登陆不同的选项卡

[英]create a link for a single page application (SPA) to land on different tab

I am developing a single page application using AngularJs.我正在使用 AngularJs 开发单页应用程序。 Depends on the users options, am showing/hiding the respective view.取决于用户选项,显示/隐藏相应的视图。

在此处输入图片说明

My URL is localhost:8086/portal/ and default landing page is Dashboard.我的 URL 是localhost:8086/portal/ ,默认登录页面是 Dashboard。

But, there is a requirement: instead of giving localhost:8086/portal/ , I need to give a link on another page like localhost:8086/portal/reports , which should land on the Reports page by default.但是,有一个要求:我不需要提供localhost:8086/portal/ ,而是需要在另一个页面上提供一个链接,例如localhost:8086/portal/reports ,默认情况下该链接应位于“报告”页面上。 As, I am developing SPA, my URL wont changes, but in this case I need to land on the same URL with different landing page,by clicking on the different link.因为,我正在开发 SPA,我的 URL 不会改变,但在这种情况下,我需要通过点击不同的链接来登陆具有不同登陆页面的相同 URL。

My solution was to use URL re-writing so you are still landing on the SPA page but with a different URL.我的解决方案是使用 URL 重写,因此您仍会登陆 SPA 页面,但使用不同的 URL。 The routing engine will pick this up and load the correct template.路由引擎将选择它并加载正确的模板。

.NET web.config example. .NET web.config 示例。

<rule name="NewsByEmail">
   <match url="^newsbyemail/" />
   <action type="Rewrite" url="/app/newsbyemail/index.html" />
</rule>

<rule name="NewsByEmailUnsubscribe">
   <match url="^newsbyemail/unsubscribe/" />
   <action type="Rewrite" url="/app/newsbyemail/index.html" />
</rule>

Angular routing.角度路由。

myApp.config(
    ($routeProvider, $locationProvider) => {
        $routeProvider
            .when("/newsbyemail/", {
                templateUrl: "app/newsbyemail/subscribe/subscribe.html"
            }).when("/newsbyemail/unsubscribe/", {
                templateUrl: "app/newsbyemail/unsubscribe/unsubscribe.html"
            });

        $locationProvider.html5Mode(true);
    }
);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用AngularJS和Sitecore(SPA)构建单页应用程序 - Building a Single Page Application with AngularJS and Sitecore (SPA) 概念说明SPA(单页应用程序) - Concept explanation SPA (Single Page Application) 每页单服务器请求与SPA应用程序 - Single Server request per page vs SPA Application PageSpeed服务/库如何帮助单页应用程序(SPA)? - How does PageSpeed Service/Library helps a Single Page Application (SPA)? 使用单页应用程序(SPA)时如何在不刷新浏览器的情况下处理过期文件? - How to handle expired files without refreshing the browser when using Single Page Application (SPA)? CSS覆盖单页面应用程序中的不同页面 - CSS overriding for different pages in Single page application 单击链接时-&gt;转到其他选项卡,而无需重新加载页面 - when clicking on a link -> go to different tab without reloading the page Angular JS - 非单页SPA的路径 - Angular JS - Route to Non Single Page SPA 如何在Angular中创建单页应用程序? - How to create single page application in Angular? 使用编码的UI自动执行针对角度SPA(单页应用程序)的UI测试时,单击主页上的图标不起作用 - While automating UI tests for angular SPA (Single Page Application) using Coded UI, clicking icons on home page does not work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM