Open Blackbaud-BobbyEarl opened 8 years ago
I think almost every action in the site should have an appropriate state. I think this better supports deep linking. One complication I got from this was how to open modals via a state. Here's an example...
For the "Go back" method, I've used this in the past. Not sure if it's the best way, but seemed to do the job.
app.run(['$rootScope', '$location', function ($rootScope, $location) { var history = []; $rootScope.$on('$routeChangeSuccess', function() { history.push($location.$$path); }); $rootScope.back = function () { var prevUrl = history.length > 1 ? history.splice(-2)[0] : "/"; $location.path(prevUrl); }; }]);
Is this the preferred directive/controller setup? Obviously the replace/restrict properties could be changed to fit the scenario.