angularjs - Angular JS RouteProvider does not call -
i'm working on e-commerce webapp learn angular. have menu on home page (common , visible on pages), provides available products e.g. books, clothes etc.
on menu have list items follows:
<li><a href="#/searchproducts" ng-click="searchproduct('computers')">computers</a></li> <li><a href="#/searchproducts" ng-click="searchproduct('academics professional')">academics & professional</a></li>
searchproduct function in first controller sets selected product in scope , sets location.path.
$scope.searchproduct =function(producttbsearched){ $scope.tbfproduct=producttbsearched; $location.path("/searchproducts"); }
i have route provider in first controller refers html , 2nd controller.
$routeprovider.when("/searchproducts", { templateurl: "./views/homesearchproducts.html" , controller: "productsearchctrl" });
in second controller, call rest ws search db , build response json. issue when click on first item on menu @ home page, search results , can see url gets changed ".......index2.html#/searchproducts"
now @ page when try choose menu item, routeprovider not call "productsearchctrl" again , no ajax call executed newly selected item. on this?
i think trying reload route. can update code below in order reload route.
$scope.searchproduct =function(producttbsearched){ $scope.tbfproduct=producttbsearched; if($location.path() === "/searchproducts") { $route.reload(); } else { $location.path("/searchproducts"); } }
Comments
Post a Comment