[英]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.