【发布时间】:2016-12-02 03:42:38
【问题描述】:
我在表上部署 json 响应时遇到问题, 这是我的controller.js
var app = angular.module('angularjs-starter', []);
app.controller('MainCtrl', function($scope, $http) {
$scope.choices = [{id: 'choice1'}];
$scope.jsonData = {};
这是我的 controler.js 中的函数,我用我的表格内容发布数据和我的 php 响应
$scope.continue = function(choices)
{
var json = $scope.choices;
$http.post('php/calculador.php', json)
.then(function(response) {
$scope.jsonData = response;
console.log($scope.jsonData);
});
};
});
我在控制台中打印了 json 数据以确保数据正确,但它没有在我的 html 表中显示任何数据
这是我的 HTML 表格 我试图在哪里部署我的 json
<div ng-app="angularjs-starter" ng-controller="MainCtrl">
<table>
<tr ng-repeat="x in jsonData">
<td>{{ x.costo_m }}</td>
<td>{{ x.desc }}</td>
<td>{{ x.id }}</td>
</tr>
这是打印在控制台上
Object
data:Array[1]
0: Array[1]
0: Object
costo_m: 18.973529411765
desc: "BLONG-F25+MOBICTRL"
id: "choice1"
licencias: 4.3
【问题讨论】: