Exclamation mark after hash (#!) in angularjs app

前端 未结 3 781
忘了有多久
忘了有多久 2020-12-02 22:24

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.

3条回答
  •  甜味超标
    2020-12-02 23:21

    Your function is missing a locationProvider and needs to specify html5Mode for the locationProvider. See https://docs.angularjs.org/api/ng/provider/$locationProvider. Instead of:

    .config(function ($routeProvider) { $routeProvider .when('/', {

    try:

    .config(function ($locationProvider, $routeProvider) { $locationProvider.html5Mode({ enabled:true }); $routeProvider .when('/',{

    By default you also need to specify a base tag in your index.html file.

提交回复
热议问题