在我的应用程序中,主模板有一个月份的下拉列表(Jan, Feb ...)。
主模板包含一个ng-view
,加载了部分模板,使用routeProvider
.
如何ng-view
从主模板的控制器刷新(通过重新运行其控制器)?
这样当用户切换到不同的月份时,部分模板内容将刷新。
主模板 HTML:
....
<body class="" ng-controller="Main">
<div ng-view></div>
</body>
路线提供者:
....
.config([ '$routeProvider', function($route) {
$route.when('/module/:module', {
templateUrl : 'partial/module.html',
controller : Module
}).otherwise({
templateUrl : 'partial/dashboard.html',
controller : Dashboard
});
} ]);
主控制器:
function Main($scope, $cookies) {
...switch month and ajax...
// Reload ng-view goes here
}