0
现在我有差异模块中的菜单指令和产品页面。如何为每次点击刷新路线,而不是改变路线?
这里类似的菜单
<ul class="nav navbar-nav" >
<li class="active">
<a href="#/product">Products</a>
</li>
</ul>
这里同类产品控制器
.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);
});
}])
,这里是routeProvider配置
$routeProvider.when('/product',{templateUrl:'/view/product',controller:'ProductCtrl'});
改变路线是success.but我需要重装产品在#/产品或需要写一个事件来获取产品ID和每次点击#清洁变量/产品?
在此先感谢
我知道,,但我已经美元$范围。在$(“$ routeChangeSuccess”)..并在那里写 –
我需要正确的位置写code..event或其他? –
内,您的$ routeChangeSuccess事件。检查新的ID是否与当前的作用域ID匹配,如果没有,则重新加载。 – geoidesic