【发布时间】:2016-08-19 20:55:43
【问题描述】:
不知道发生了什么,但我没有在我的网页上使用带有模板的 ng-repeat 显示任何内容。
这是显示数据的图片
This pic shows my console.log output with array of objects
不知道为什么不只显示在网页上!
Devices: Array[17]
0 : Object
Aid : "....."
...
1 : Object
带功能的角控制器
(function () {
'use strict';
angular.module('app').controller('DeviceController', DeviceController);
function DeviceController($http){
var vm = this;
var dataService = $http;
//dataService.get("/api/Product")
vm.devices = [];
deviceList();
function deviceList() {
dataService.get("http://localhost:42822/api/device")
.then(function (result) {
vm.devices = result.data;
//debugger;
console.log(vm.devices);
},
function (error) {
handleException(error);
});
}
function handleException(error) {
alert(error.data.ExceptionMessage);
}
}
})();
HTML
<html>
<head> </head>
<body>
<div ng-app="app" ng-controller="DeviceController as vm">
<div>test</div><br>
<table>
<tbody>
<tr ng-repeat="device in vm.devices">
<td>{{device.Aid}}</td>
<td>{{device.DeviceId}}</td>
</tr>
</tbody>
</table>
</div>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js"></script>
<!--<script src="~/Scripts/angular.min.js"></script>-->
<script src="./app/app.module.js"></script>
<script src="./app/device.controller.js"></script>
</html>
不知道为什么不只显示在网页上!
【问题讨论】:
标签: javascript asp.net angularjs arrays ajax