0

I have an Angular 1.3 project, using ng-route. I am using Angular Toastr for user notifications.

After the notification closes, I want to send the user to a path.

With the following code, the even fires my function and displays the debug statement, but the browser does not navigate and no errors are shown. What did I miss?

  $scope.sendUsername = function() {
if ($scope.myForm.$valid) {
  toastr.success('We sent an email to (email address)', {
    onHidden: function() {
      $log.debug('foo');
      $location.path('/');
    }
  });
}
 };
Steve
  • 14,401
  • 35
  • 125
  • 230
  • does it work if you use .url instead of .path? – Joel Apr 01 '15 at 21:51
  • FWIW, the only thing I was able to get to work was `window.history.back(); ` – Steve Apr 02 '15 at 12:39
  • The only thing i can think is that it's because $location is being used outside of the angular scope in the onHidden callback. After you do $location.path, try manually notifying angular that things have changed with $scope.$apply(). – Joel Apr 02 '15 at 13:47
  • Assuming that Angular toastr is anything like vanilla toastr, the second argument for the toast.success function is the title. You're passing it a function. – Tim Ferrell Jun 05 '15 at 04:11

1 Answers1

0
toaster.pop('success',null, 'Candidate added successfully', null, '');
                              var delay=1000; //1 seconds

                             setTimeout(function(){
                             $location.path('/new location');          
                         }, delay); 
Mahesan Rv
  • 318
  • 4
  • 4