我从API访问JSON对象,迭代它并将信息存储在变量中。所有上述步骤都在控制器中执行。但是当我尝试获取这些变量并将其显示在视图文件中时,视图文件无法识别变量。
controller.js
(function () {
"use strict";
angular
.module("app.widgets.health.security.threat")
.controller("ThreatController", ThreatController);
ThreatController.$inject = [
"$scope",
"$rootScope",
"$interval",
"logger",
"config",
"gettextCatalog",
"brandingService",
"appConfig",
"$http"
];
function ThreatController ($scope,
$rootScope,
$interval,
logger,
config,
gettextCatalog,
brandingService,
appConfig,
$http) {
var vm = this;
activate();
function activate () {
var i;
var j;
i18n();
vm.threatData = [];
$http.get("/objects/health-threats").then (
function (responseData) {
vm.threatData = responseData.data;
for (i = 0; i < vm.threatData.objects.length; i++) {
logger.info("feedData", vm.threatData.objects[i]);
vm.healthData = vm.threatData.objects[i];
}
}
);
}
})();
view.html
<div translate class="label-base">Feeds {{ vm.threatData }}</div>
记录器语句给出正确的结果但是当我尝试在视图中显示时,它不会打印任何结果。请帮忙!
答案 0 :(得分:0)
请复制粘贴console.log(vm.threatdata)的输出。