从我的Angular应用程序中我需要从URL中删除#值。作为一个示例,我需要使用参数名称CAL name
执行此URL,然后在HTML页面中显示。
示例:
此URL:
http://localhost/angular_ex/url.html#?name = test
in:
http://localhost/angular_ex/url.html?name = test
因为从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>
index.js
var newApp = angular.module('HelloApp', []);
newApp.controller('myCtrl', newAppConstructor);
newAppConstructor.$inject = ['$scope', '$location'];
function newAppConstructor($scope, $location) {
$scope.name = $location.search().name;
}
尝试此答案
newApp.config(function($locationProvider) {
$locationProvider.html5Mode({
enabled: true,
requireBase: false
});
})