기본 페이지가 있습니다. 범위에서 수동으로 json 데이터를 정의 할 수 있으며, 모든 것이 잘 작동합니다.
예 :
<!DOCTYPE html>
<html ng-app="ordersApp">
<head>
<scrip src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.15/angular.js"></scrip>
</head>
<body>
<h1>Recent Orders</h1>
<table ng-controller="orderCtrl">
<tr>
<th>Order Date</th>
<th>Stock Description</th>
<th>Order #</th>
<th>Order Value</th>
</tr>
<tr ng-repeat="item in orders track by $index">
<td>[[item.oh_statusdate]]</td>
<td>[[item.ol_stockdesc]]</td>
<td>[[item.oh_orderno]]</td>
<td>[[item.oh_ordervalue]]</td>
</tr>
</table>
<scrip>
// register the app
var ordersApp = angular.module('ordersApp', []);
// alllow [[var]] instead of {{var}} for jinja2
this.ordersApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
// create a controller inside the app
ordersApp.controller('orderCtrl', function ($scope) {
// assign the json data
$scope.orders = [
{"ol_stockdesc": "EALANT",
"oh_statusdate": "2014-07-02",
"oh_custaccref": "416",
"oh_ordervalue": null,
"oh_orderno": 449605},
{"ol_stockdesc": " BAG 25kg A",
"oh_statusdate": "2014-07-04",
"oh_custaccref": "416",
"oh_ordervalue": null,
"oh_orderno": 449824},
{"ol_stockdesc": "BOTTLE B",
"oh_statusdate": "2014-07-04",
"oh_custaccref": "416",
"oh_ordervalue": null,
"oh_orderno": 449824},
{"ol_stockdesc": "CREDIT CARD ADMIN & SURCHARGE",
"oh_statusdate": "2014-07-04",
"oh_custaccref": "416",
"oh_ordervalue": null,
"oh_orderno": 449824}
];
});
</scrip>
</body>
</html>
위의 작품 잘, 나는 일을하려고하지만 경우 다음
// register the app
var ordersApp = angular.module('ordersApp', []);
// alllow [[var]] instead of {{var}} for jinja2
this.ordersApp.config(function($interpolateProvider) {
$interpolateProvider.startSymbol('[[');
$interpolateProvider.endSymbol(']]');
});
ordersApp.controller("orderCtrl", function($scope, $http) {
$http.get('http://0.0.0.0:6543/orders.json?customer=416').
success(function(data, status, headers, config) {
$scope.orders = data;
}).
error(function(data, status, headers, config) {
// log error
});
});
그것은 작동하지 않습니다 내가 개발 도구와 요청을 검사하고 볼 수있는 데이터 요청이 성공적으로 이루어지고 $ scope와 내 데이터가 검사되면 콘솔에서도 오류를 기록하지 않습니다. 누군가가 이것에 대해 약간의 빛을 비출 수 있다면 그것은 크게 감사 할 것입니다. 방화벽으로 인해 태그를 게시 할 수 없으므로 예제 코드는 "스크립트"대신 "스크립트"로 표시됩니다.
json _exactly_가 동일한가요? –
예, 정확하게 동일합니다. – crooksey
''및 ' '태그는 오타가 있습니까? –