[英]Using ngView directive without hash in angularjs
AngularJS部分:
myApp.config(['$routeProvider','$locationProvider',function($routeProvider,$locationProvider) {
$routeProvider.
when('/main', {templateUrl: 'sub/main.tpl', controller: MainCtrl}).
when('/users', {templateUrl: 'sub/users.tpl', controller: UserCtrl}).
otherwise({redirectTo: '/main'});
}]);
和我的index.html
<a href="#/main">Main</a> | <a href="#/users">Display Users</a>
<div ng-view></div>
它很好用,但是我在哈希上遇到了問題。
當我嘗試使用錨,即:
<a href="#test">test</a>
當我單擊該錨點時,它正在調用主頁。
當我們使用ng-view時,是否有可能消除哈希值?
嗯,因為AngularJS會重新路由您的網址。 嘗試使用ng-href,
<a ng-href="#test">test</a>
編輯:您可以嘗試將錨點的ID更改為角度網址。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.