是否会是我的代码有问题: 比如rest访问
angular.module('nmsRealtime', ['angular-echarts', 'ngResource',
'ngTable', 'ngSanitize'])
.controller('nmsRealtimeCtrl',
['$log', '$scope', '$timeout', '$routeParams', '$location',
'$resource',
'NgTableParams', '$sce',
function($log, $scope, $timeout, $routeParams, $location, $resource,
NgTableParams, $sce) {
// render_realtime_fabric 通过$resource获取REST返回的数据集
// 该数据集加工、计算之后的数据, 通过angular绑定和渲染
//
var processor_map = {'switches': render_realtime_switches,
'fabric': render_realtime_fabric};
$scope.rowIndex = 0;
$scope.selectOnSwitch = function(index) {
$scope.rowIndex = index;
}
var type = '';
var id = ''; // currently not use
if ($routeParams.hasOwnProperty('type')) {
type = $routeParams.type;
id = $routeParams.id;
}
var url = '/api/realtime/';
switch(type) {
case '':
type = 'fabric';
case 'fabric':
case 'switches':
case 'ports':
url += ':' + type;
break;
}
var Todo = $resource('/api/realtime/:metric', {metric: "@id"});
refresh();
var timer;
function loop() {
timer = $timeout(function() {
}, 10000);
timer.then(function() {
if (refresh()) {
loop();
}
else { // quit
}
});
}
loop();
function refresh() {
++counter;
$scope.callcount = counter;
// $log.debug(counter);
return processor_map[type]($scope, Todo, $sce);
}
$scope.$on("$destroy", function (event) {
$timeout.cancel(timer);
});
}])
}());
--
修改:saynothing FROM 107.178.194.*
FROM 107.178.194.*