【发布时间】:2018-11-04 22:10:58
【问题描述】:
我想使用 AngularJs 使用 web api 来使用 c# 创建仪表板。我成功使用了 web api,但是当我想添加 angular Js 来创建我的仪表板时,什么也没有出现。我不知道是什么问题。
脚本.js
var app = angular.module("DemandeApp", []); app.controller("DemCreditController", function ($scope, $http) {
$http.get("http://localhost:2573/api/demandes")
.then(function (response) {
$scope.labels = [];
$scope.data = [];
angular.forEach(response.data, function (value, key) {
$scope.labels[key] = value.libelle;
$scope.data[key] = value.quantite;
}
);
});
});
index.html:
<body ng-app="DemandeApp">
<div ng-controller="DemCreditController">
<canvas id="pie" class="chart chart-pie"
chart-data="data" chart-labels="labels" ></canvas>
</div></body>
【问题讨论】:
-
你需要将数据推送到数组中
标签: c# angularjs asp.net-web-api