<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
<script data-require="angular.js@*" data-semver="1.3.4" src="//ajax.googleapis.com/ajax/libs/angularjs/1.3.4/angular.min.js"></script>
<script src="script.js"></script>
</head>
<body >
<h1>Hello Plunker!</h1>
<div ng-app="alaexpress" ng-controller="ordenes">
<table>
<tr ng-repeat="detalle in detalles ">
<td>
{{detalle.uuid}}
</td>
</tr>
</table>
</div>
<script>
var app = angular.module('alaexpress', []);
app.controller('ordenes', ['$scope', '$http', function($scope, $http) {
$scope.getDetalles = function() {
$http.get("archivo.json").success(function (data, status, headers, config) {
$scope.detalle = {
cantidad: 1,
costo: 0,
direccionid: "",
materialid: "",
iva: function() {
return this.cantidad * this.costo * 0.16
},
subtotal: function() {
return this.cantidad * this.costo
},
direccion: "",
uuid: Date.now(),
fecha: ""};
$scope.iva = 0;
$scope.subtotal = 0;
$scope.total = 0;
angular.forEach(data, function(value) {
console.log(value["material"].codigo);
//console.log(key);
$scope.detalles.push({
cantidad: value.cantidadrequerida,
costo: value.costo,
material: value["material"].codigo,
direccionid: value["envios"][0].direccion_id,
materialid: value.material_id,
iva: function() {
return this.cantidad * this.costo * 0.16
},
subtotal: function() {
return this.cantidad * this.costo
},
direccion: value["envios"][0]["direccion"].nombre,
uuid: value.id,
fecha: value.fechaproyeccion
});
});
})
};
}]);
</script>
</body>
</html>
// Code goes here
/* Styles go here */
[
{
"id":65,
"orden_id":26,
"material_id":65,
"fechaproyeccion":"2014-11-25T00:00:00.000-08:00",
"fechaentrega":null,
"cantidadrequerida":1,
"cantidadliberada":null,
"created_at":"2014-11-25T08:49:16.968-08:00",
"updated_at":"2014-11-25T08:49:16.968-08:00",
"urgente":false,
"statustrafico":null,
"status":false,
"costo":23.0,
"iva":3.68,
"total":23.0,
"addiva":null,
"envios":[
{
"id":46,
"detalle_id":65,
"customer":null,
"fecha":null,
"created_at":"2014-11-25T08:49:16.970-08:00",
"updated_at":"2014-11-25T08:49:16.970-08:00",
"unit":null,
"materialt":null,
"destination":null,
"origen_id":null,
"persona_id":null,
"direccion_id":1,
"adelanto":null,
"material_id":null,
"cartaporte_fraccion":null,
"cartaporte_clase":null,
"cartaporte_pedimento":null,
"cartaporte_cuota":null,
"cartaporte_valor":null,
"cartaporte_paisorigen":null,
"cartaporte_destino":null,
"cartaporte_reembarco":null,
"cartaporte_condujode":null,
"cartaporte_condujoa":null,
"cartaporte_reembarcon":null,
"cartaporte_conducirde":null,
"cartaporte_conducira":null,
"cartaporte_concepto":null,
"cartaporte_pesoeta":null,
"cartaporte_mts2":null,
"cartaporte_embalaje":null,
"cartaporte_precio":null,
"statusviaje":false,
"cartaporte_valorletra":null,
"adelantopapeles":null,
"direccion":{
"id":1,
"nombre":"HYUNDAI DE MEXICO SA DE CV",
"locacion":"LA ENCANTADA TIJUANA BAJA CALIFORNIA",
"tipo":1,
"latitud":null,
"longitud":null,
"paginaweb":null,
"horarioatencion":"7 a 5 lunes a viernes",
"created_at":"2014-10-17T04:52:00.000-07:00",
"updated_at":"2014-10-17T04:52:00.000-07:00",
"costo":null,
"rfc":null
}
}
]
},
{
"id":66,
"orden_id":26,
"material_id":65,
"fechaproyeccion":"2014-11-26T00:00:00.000-08:00",
"fechaentrega":null,
"cantidadrequerida":1,
"cantidadliberada":null,
"created_at":"2014-11-25T08:49:17.097-08:00",
"updated_at":"2014-11-25T08:49:17.097-08:00",
"urgente":false,
"statustrafico":null,
"status":false,
"costo":100.0,
"iva":16.0,
"total":100.0,
"addiva":null,
"envios":[
{
"id":47,
"detalle_id":66,
"customer":null,
"fecha":null,
"created_at":"2014-11-25T08:49:17.098-08:00",
"updated_at":"2014-11-25T08:49:17.098-08:00",
"unit":null,
"materialt":null,
"destination":null,
"origen_id":null,
"persona_id":null,
"direccion_id":75,
"adelanto":null,
"material_id":null,
"cartaporte_fraccion":null,
"cartaporte_clase":null,
"cartaporte_pedimento":null,
"cartaporte_cuota":null,
"cartaporte_valor":null,
"cartaporte_paisorigen":null,
"cartaporte_destino":null,
"cartaporte_reembarco":null,
"cartaporte_condujode":null,
"cartaporte_condujoa":null,
"cartaporte_reembarcon":null,
"cartaporte_conducirde":null,
"cartaporte_conducira":null,
"cartaporte_concepto":null,
"cartaporte_pesoeta":null,
"cartaporte_mts2":null,
"cartaporte_embalaje":null,
"cartaporte_precio":null,
"statusviaje":false,
"cartaporte_valorletra":null,
"adelantopapeles":null,
"direccion":{
"id":75,
"nombre":"Tecate 2 (PICK UP TIME @ HYUNDAI)",
"locacion":"Hay que agregar la direccion",
"tipo":3,
"latitud":"",
"longitud":"",
"paginaweb":"",
"horarioatencion":"7am a 5 pm",
"created_at":"2014-10-23T06:32:31.575-07:00",
"updated_at":"2014-11-21T13:17:55.978-08:00",
"costo":100.0,
"rfc":""
}
}
]
}
]