Angularjs如何在没有散列爆炸的情况下制作ngRoute
在我的angularjs应用程序中,我在公用文件夹中有index.html,其中包含以下代码Angularjs如何在没有散列爆炸的情况下制作ngRoute,angularjs,ngroute,angularjs-ng-route,Angularjs,Ngroute,Angularjs Ng Route,在我的angularjs应用程序中,我在公用文件夹中有index.html,其中包含以下代码 <body ng-controller="TheController"> <div id="startdiv"> <label>Username</label><input type="text" tabindex="1" placeholder="Enter Your User Name" name="email" requ
<body ng-controller="TheController">
<div id="startdiv">
<label>Username</label><input type="text" tabindex="1" placeholder="Enter Your User Name" name="email" required>
<label>Password</label><input type="password" tabindex="2" placeholder="Enter Your Password" name="password" required>
<br><br>
<button ng-click="saveData()">Login</button><button ng-click="saveData()">SignUp</button><br>
<button ng-click="changeview()">ClickMe</button>
</div>
</body>
此外,我还有london.html在我想在点击按钮时加载的同一个公用文件夹中
my london.html
<h1>London</h1>
<h3>London is the capital city of England.</h3>
伦敦
伦敦是英国的首都。
问题是,单击按钮时,url将从“”更改为“”,但未加载html页面。我还想知道是否可以使用散列字符进行路由
请告诉我哪里出错了。
谢谢。在
app.module.js
$locationProvider.html5Mode(true)
示例:
window.routes = {
'/': {
templateUrl: 'app/visitor/visitor.html',
anonymous: true
},
'/index': {
templateUrl: 'app/visitor/visitor.html',
caseInsensitiveMatch: true,
anonymous: true
},
'/lu/:mt?/:tab?/:id?': {
templateUrl: 'app/user/user.html',
caseInsensitiveMatch: true,
anonymous: false
}
};
app.config(function ($routeProvider, $locationProvider) {
for (var path in window.routes) {
$routeProvider.when(path, window.routes[path]);
}
$routeProvider.otherwise({redirectTo: '/'});
$locationProvider.html5Mode(true);
});
同样作为示例中的
templateUrl:'app/visitor/visitor.html',
设置文件的完整路径。请编辑问题,将其限制为特定问题,并提供足够详细的信息,以确定适当的答案。避免同时问多个不同的问题。
window.routes = {
'/': {
templateUrl: 'app/visitor/visitor.html',
anonymous: true
},
'/index': {
templateUrl: 'app/visitor/visitor.html',
caseInsensitiveMatch: true,
anonymous: true
},
'/lu/:mt?/:tab?/:id?': {
templateUrl: 'app/user/user.html',
caseInsensitiveMatch: true,
anonymous: false
}
};
app.config(function ($routeProvider, $locationProvider) {
for (var path in window.routes) {
$routeProvider.when(path, window.routes[path]);
}
$routeProvider.otherwise({redirectTo: '/'});
$locationProvider.html5Mode(true);
});