angularjs - how to per click to reload route and not change route? -


now have menu directive , product page in diff module.

here similar menu

<ul class="nav navbar-nav" >     <li class="active">     <a  href="#/product">products</a>     </li> </ul> 

here similar product controller

.controller('productctrl', ['$scope','flash','$http','fileuploader','$filter','$cookiestore', function ($scope,flash,$http,fileuploader,$filter,cookie) { $scope.$on('$routechangesuccess', function(angularevent, current, previous) {     if ('new_id' in current.params){             $scope.product_id = current.params.new_id;             $http.get('/v2/oauth/product/'+current.params.new_id).success(function(data,state,headers,config){                 if(state==200){                     $scope.product_id = data.answer._id;                     setproduct_variable(data.answer);                     flash('get product info:'+data.answer['name']);                 }             })     }else{        $http.post('/v2/oauth/product/new').success(function(data,state,headers,config) {             if (state ==200){$scope.product_id =data}         });         flash('get new product id!');     }     //console.log(current.params); }); }]) 

and here routeprovider config

$routeprovider.when('/product',{templateurl:'/view/product',controller:'productctrl'}); 

change route success.but need reload product in #/product or need write event getproductid , clean variable in per click #/product ?

thanks in advance

try this:

$route.reload(); 

from manual:

https://docs.angularjs.org/api/ngroute/service/$route

you'll need inject $route controller.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -