angularjs应用中井号(#!)之后的感叹号 [英] Exclamation mark after hash (#!) in angularjs app
问题描述
我刚刚发现我所有的路径中的井号(#!)后都有一个感叹号.我不确定如何以及为什么获得它们,因为今天早些时候我没有它们.
I have just noticed that I have an exclamation mark after a hash (#!) in all of my routes. I'm not sure how and why I got them because earlier today I didn't have them.
如果有什么解决办法可以摆脱它们,那么如果有人可以向我解释一下(以及我如何拥有它们),我将不胜感激.
If there is any solution to get rid of them, I would appreciate if someone can explain me what is it( and how I came to have them).
因此,到目前为止,我发现的唯一解决方案是在应用程序中的每个href上手动加上惊叹号,但这使我很烦,我也不知道该怎么办.
So, the only solution that I have found so far is to put manually put the exclamation mark on every href in my app, but this annoys me and I have no idea what to do.
我用yeoman生成器生成了我的应用,而我的app.js看起来像这样:
I generated my app with yeoman generator and my app.js looks like this:
angular
.module('appNameApp', [
'ngAnimate',
'ngCookies',
'ngResource',
'ngRoute',
'ngSanitize',
'ngTouch'
])
.config(function ($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/main.html',
controller: 'MainCtrl',
controllerAs: 'main'
})
.when('/about', {
templateUrl: 'views/about.html',
controller: 'AboutCtrl',
controllerAs: 'about'
})
.when('/jaspo', {
templateUrl: 'views/about.html',
controller: 'jaspoCtrl',
controllerAs: 'vm'
})
.otherwise({
redirectTo: '/'
});
});
推荐答案
修改这两行:
.config(function ($routeProvider) {
$routeProvider
成为:
.config(function ($routeProvider,$locationProvider) {
$locationProvider.hashPrefix('');
$routeProvider
信用应转到: https://stackoverflow.com/a/41223197/1564146
这篇关于angularjs应用中井号(#!)之后的感叹号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!