$location.path('view') - Cannot read property 'originalPath' of undefined


#1

I have a scenario, showing results when search form is submitted.

//app.html
Search

// controllers.js
.controller(‘AdoptTabCtrl’, function($scope, $location){

$scope.search = function(view) {
	 /** Do form submission stuff, on successful navigate to another view**/
 	$location.path('view'); 
};

})

Code works fine, but $location.path(‘view’); statement throwing the below error…

TypeError: Cannot read property ‘originalPath’ of undefined
at /js/ionic-angular.js:25357:44
at Scope.$broadcast (/js/ionic-angular.js:11865:28)
at updateRoute (/js/ionic-angular.js:23557:20)
at Scope.$broadcast (/js/ionic-angular.js:11865:28)
at afterLocationChange (/js/ionic-angular.js:8963:18)
at /js/ionic-angular.js:8951:13
at Scope.$eval /js/ionic-angular.js:11590:28)
at Scope.$digest (/js/ionic-angular.js:11435:31)
at Scope.$apply (/js/ionic-angular.js:11696:24)
at HTMLButtonElement. (/js/ionic-angular.js:22922:13) ionic-angular.js:9115


#2

Hey @dhondi_srikanth. I’m not sure why the issue is happening, but I did add a check in the code to stop the error from throwing. It looks like maybe there isn’t a route registered for that, or because this is triggered using $location, the route isn’t getting handled?

At any rate, try the new release and let me know if that fixes it for you: https://github.com/driftyco/ionic/releases/tag/v0.9.13-alpha


#3

Yes, route not registered for the view. Now it’s corrected. works very cool now.