Search code examples
jsonangularjsdata-bindingangularjs-routingng-view

AngularJs : two page routing won't work for changing views , status code : 404


As a newbie in Angular, i am working a tutorial : WEB DEVELOPMENT WITH_ANGULARJS AND BOOTSTRAP via "Packt".

Below is the link in plunker to check the code implementation.

At the moment i am working on the Routing Events, specificly a login form where i added 2 links to change the view from the Login form to Report. The error i receive is when i click on these links it returns :

{ "statusCode": 404,"error": "Not Found"}

Furthermore the data binding for the "report" template won't work as well.

The version of Angular that is been used in the tutorial is AngularJs v1.3.0, however i am using v1.4.6 and no problem have been occurred so far!

While most of the similar issue posts refer to a version compatibility issue , in my case any version of Angular i used it produces the same error.

Have i done anything wrong in the script.js configuration?


Solution

  • The href's you are using don't include the hash and proper angular path.

    Change:

    <a href="login">Login</a>
    <a href="report">Report</a>
    

    To:

    <a href="#/login">Login</a>
    <a href="#/report">Report</a>