在使用angular-route设置路由时,页面href不正确,如下:[app.html]
...
<custom />
...
<script>
...
app.config(["$routeProvider", function ($routeProvider) {
$routeProvider.when("/checkout", {
templateUrl: "views/checkoutSummary.html",
});
$routeProvider.when("/products", {
templateUrl: "views/productList.html"
});
$routeProvider.otherwise({
templateUrl: "/views/productList.html",
})
}])
...
</script>custom指令引入模版如下(由于只有路由有问题,这里的代码不包含没有问题的代码):<div class="navbar-right">
<div class="navbar-text">
<b>购物车:</b>
{{itemCount()}} 个商品, {{total() | currency}}
</div>
<a href="#/checkout" class="btn btn-default navbar-btn">结算</a></div>点击a元素时,浏览器路径显示为:http://localhost:3000/app.html#!#%2Fcheckout错误路径取到的$location.hash()为"/checkout"正确的路径应为:http://localhost:3000/app.html#!/checkout或者http://localhost:3000/app.html#!%2Fcheckout请问是什么原因,导致点击链接的时候自动给多加了一个#在!后面?
添加回答
举报
0/150
提交
取消