我已经google了很多但是找不到解决这个问题的方法。我有一个像'external / user / login / example.php'这样的相对路径,在这种情况下我需要绕过角度路由来获取my_env + relative_url。
角度有可能吗?提前谢谢。
答案 0 :(得分:0)
好吧,如果您使用RouterLink
或其中一种navigate
方法导航到该网址,请执行操作。您只需使用浏览器API直接导航,绕过Angular:
window.location = ' /external/user/example.php';
当然,您必须确保此路由不会将您发送到托管的Angular应用程序的html文档。您可能必须检查服务器的路由配置。
答案 1 :(得分:0)
您可以在Angular Web.config文件中尝试此操作
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url="^bulletinboardapi/?" negate="true"/>
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="/index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
说明
<match url="^bypassPath/?" negate="true"/> tag tells angular that if URL comes without /bypassPath/ then route as per angular.
www.yourwebsite.com/bypassPath/api/user/get will go to your API path (Server). In many cases bypassPath may be your virtual application pointing to your API project.
www.yourwebsite.com/login/ will route as per angular even if you refresh browser.
www.yourwebsite.com/home/ will route as per angular even if you refresh browser.
希望这会有所帮助!