0

i am coding an angular app i already created my app routing

AdminDashboard.config(['$routeProvider','$locationProvider',function($routeProvider, $locationProvider){    
    $routeProvider
        .when('/',{
            templateUrl: '../dashboard/administration/dashboard.html',
            controller : 'Dashboard'}
            )
            //Students Routes
        .when('/Students', {
            templateUrl : '../dashboard/administration/students/students.html',
            controller: 'ShowStudentsController'}
             )
        .when('/Students/:studentId/edit',{
            templateUrl : '../dashboard/administration/students/modals/edit.html',
            controller: 'EditStudentsController'
        })
        .when('/Students/create',{
            templateUrl : '../dashboard/administration/students/modals/create.html',
            controller: 'CreateStudentsController'
        });
        }]);

and the history wasn't working i did a research on Anuglar API and i found that i've to add.

$locationProvider.html5Mode(true); 

and then the browser back button was working and getting to the previous route but the template won't render. Please help me. And i hope my question is clear.

Yassine
  • 55
  • 1
  • 9
  • Here is a post on Angular Back button http://stackoverflow.com/questions/14070285/how-to-implement-history-back-in-angular-js – Paul John Mar 01 '15 at 13:21
  • The console is always saying the angular.map files are missing? – Yassine Mar 01 '15 at 13:26
  • Thanks Paul, thats one solution. but how can i handle the browser back button – Yassine Mar 01 '15 at 13:30
  • what's happening with the browser back button now? ANy errors? – Paul John Mar 01 '15 at 13:38
  • Without adding the locationProvider it's not returning to the previous page but the template of the actual page is working normally, but when adding the locationProvider the history mapping is working but no template rendering and the only errors that are showing are the missing map files and that was the case even before adding the locationProvider. – Yassine Mar 01 '15 at 13:47
  • @Cine get your map files http://code.angularjs.org/1.2.12/ – underscore Mar 01 '15 at 14:13
  • Done, but sadly nothing changed except there is no map errors now. – Yassine Mar 01 '15 at 14:27
  • Never seen this issue and you don't need `html5mode` either for routing to work ( assuming using hash). SOmething else is wrong in your app – charlietfl Mar 01 '15 at 14:36
  • The result of my route url is somthing like this /Administration#/Students shouldn't be like this /Administration/#/Students? – Yassine Mar 01 '15 at 14:41
  • I really don't know what might be wrong since the console is clear what you suggest me to do @charlietfl? – Yassine Mar 01 '15 at 14:42
  • WHat are you using for href? – charlietfl Mar 01 '15 at 14:45
  • It works now indeed it was an error in href ^^ Thanks for help @charlietfl really appreciate it. – Yassine Mar 01 '15 at 14:50

1 Answers1

0

(sorry, my rep is too low to add this as a comment but...)

I had a similar weird problem with routing not working earlier and it turned out to be a stray # link from the basic page design. I'm sure there's a perfectly good reason for that, but clicking on this # link would break all browser navigation for the remainder of the session.

Replacing those # hrefs with #/ prevented the problem for me.

Fasermaler
  • 943
  • 6
  • 14
  • 1
    Thanks, for bringing me joy ^^ really appreciate it. it worked just fine now – Yassine Mar 01 '15 at 14:45
  • You're welcome, I ended up implementing all sorts of providers and services and whatnot until I finally realized what was actually causing the problem. Glad to have saved you something of that aggravation :) – Fasermaler Mar 01 '15 at 14:49