如何为重新加载

时间:2017-01-19 09:35:49

标签: angularjs

我想使用$ rout来做

$scope.reloadRoute = function() {
    $route.reload();
};

在我发现的所有示例中,我需要加载ngRoute模块 所以我将angular-route.min.js添加到我的index.html并添加了ngRoute

var app = angular.module('gifts_and_parties', ['smart-table','ngRoute'])

然后我的应用程序崩溃了。

1 个答案:

答案 0 :(得分:0)

问题可能是您没有在$route中注入controller,还要检查您是否在index.html中包含angular-route

Mypp.controller('Ctrl', [
    '$scope', '$route',
    function($scope,$route) {
         $route.reload();
     };
    }
]);

其次,如果您想重新加载整个页面,可能需要使用$window.location.reload();