[英]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.