0

I'm doing an application using OAuth so first of, a php-page is loaded to authenticate with OAuth. When finished the callback php script redirects to the start page of my angular application.

//  Redirect user to the startpage of the application
header("location: http://localhost/app/start.html");

Here, Angular is instantiated, all scripts are loaded and the stateprovider is supposed to redirect to the .otherwise state here.

app
.config(function($stateProvider, $urlRouterProvider){

$urlRouterProvider.otherwise('main/front');

$stateProvider
.state('main',{
    url: '/main',
    abstract: true,
    templateUrl:'templates/menu.html'
})

    .state('main.frontpage',{
        url: '/front',
        templateUrl:'templates/frontPage.html'
    })
});

The redirect works fine and i'm getting to the correct page main/front though i'm getting a weird url that JQuery keeps alarming about.

http://localhost/app/start.html#!/main/front

JQuery error:

Uncaught Error: Syntax error, unrecognized expression: #!/main/front

Why is the url getting the #! sign in there?

EDIT: The JQuery error appears to be thrown else where. not relevant to this question.

Timothy Karvonen
  • 347
  • 1
  • 2
  • 9

1 Answers1

1

I got resolved with following code.

 $locationProvider.hashPrefix('');

or else go Routing issue with AngularJS project using yeoman setup

Community
  • 1
  • 1
Shiva
  • 358
  • 2
  • 15
  • I went through that rabbit hole and got to the page https://github.com/yeoman/generator-angular/issues/1380 where they recommended downgrading to angular 1.5.8. This appears to remove the "!", still leaving the "#". JQuery is still throwing error at this >"Uncaught Error: Syntax error, unrecognized expression: #/front" – Timothy Karvonen Jan 02 '17 at 13:30
  • No need to downgrade @TimothyKarvonen and you can check after that.my version not changed after adding that – Shiva Jan 02 '17 at 13:35
  • correct, with your solution @Shiva it removes the "!" at angular 1.6.0. Then why is JQuery complaining about the url? – Timothy Karvonen Jan 02 '17 at 13:40
  • Oh.. This appears to ba a problem outside angular, the error is thrown in a different part of my application. debugging java script amirite. Thanks @Shiva for your help – Timothy Karvonen Jan 02 '17 at 13:49