2014-02-27 52 views
0

我们有路线配置

$routeProvider 
    .when('/Search', { templateUrl: 'Search.html', controller: 'SearchCtrl' }) 
    .when('/Accounts', { templateUrl: 'Accounts.html', controller: 'AccountsCtrl' }) 
    .otherwise({ redirectTo: '/Search' }); 

在控制器已经BTN点击它重装路线

$location.path("/Accounts").search({ 
     AccountOrShortName: i.AccountOrShortName, 
});   
$route.reload(); 

AccountsCtrl是越来越执行两次。

回答

0

是的,你的代码100%负载切切实实的控制器有更多的时间

第1次),当点击链接

第二次)当此线路呼叫$route.reload(); //此代码重新加载页面

第3,第4,第5 ......,n次)的页面将被加载,每当$route.reload();代码调用

所以,你笑在第二次重新加载页面之前,请致电返回false。