Javascript AngularJs在从url中删除哈希符号(#)后使用url参数
从angular应用程序中,我需要从URL中删除#值。例如,我需要使用参数名称calJavascript AngularJs在从url中删除哈希符号(#)后使用url参数,javascript,angularjs,Javascript,Angularjs,从angular应用程序中,我需要从URL中删除#值。例如,我需要使用参数名称calname执行此URL,然后它会显示在html页面中 例如: 此URL: <!DOCTYPE html> <html ng-app="HelloApp"> <head> <script src="./angular/angular.js"></script> <script src="https://code.jquery.com/j
name
执行此URL,然后它会显示在html页面中
例如:
此URL:
<!DOCTYPE html>
<html ng-app="HelloApp">
<head>
<script src="./angular/angular.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="index.js"></script>
</head>
<body ng-controller="myCtrl">
<p>Url parameter value is :{{name}}</p>
</body>
</html>
输入到:
<!DOCTYPE html>
<html ng-app="HelloApp">
<head>
<script src="./angular/angular.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="index.js"></script>
</head>
<body ng-controller="myCtrl">
<p>Url parameter value is :{{name}}</p>
</body>
</html>
因为from C#WebRequest类不允许将web请求与哈希值一起发送
我也尝试使用这个堆栈溢出
Html代码:
<!DOCTYPE html>
<html ng-app="HelloApp">
<head>
<script src="./angular/angular.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8=" crossorigin="anonymous"></script>
<script src="index.js"></script>
</head>
<body ng-controller="myCtrl">
<p>Url parameter value is :{{name}}</p>
</body>
</html>
试试这个答案
newApp.config(function($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
})
也许这能帮你找到你的路线?您是否添加了
$locationProvider.html5Mode(true)