【发布时间】:2018-10-16 09:51:09
【问题描述】:
我是 AngularJS 编程的新手。所以我在我的 html 中调用 getDevice() 范围函数,我似乎进入了无限循环。控制台日志:
angular.js:14800 Error: [$rootScope:infdig] http://errors.angularjs.org/1.6.9/$rootScope/infdig?p0=10&p1=%5B%5D
at angular.js:88
at m.$digest (angular.js:18418)
at m.$apply (angular.js:18649)
at l (angular.js:12627)
at t (angular.js:12871)
at XMLHttpRequest.A.onerror (angular.js:12799)
代码: 应用.js
var myApp = angular.module('myApp', []);
myApp.controller('myController', function($scope, $location, $http)
{
$scope.getDevice = function(deviceId)
{
$http.get('http://localhost:8080/client/' + deviceId + '/receive/device')
.then(function (response)
{
$scope.jsondata = response.data;
})
console.log("working");
};
});
html
<body>
<div ng-app="myApp" ng-controller="myController">
{{getDevice("elsysDev")}}
</div>
</body>
那我做错了什么?
【问题讨论】:
-
在您的控制器端调用函数只需将 jsondata 打印到 html 端
-
不能解决问题
-
错误是什么?
标签: html angularjs angularjs-scope