如何从控制台angularjs显示数据

时间:2014-03-10 09:38:22

标签: javascript angularjs

我有一个控制器,我可以通过state中的id检索数据。如何在模板中显示这些控制台数据?

app.controller('DetailCtrl', function($scope, $http, Inventory, Tags, User, $location, sharedService, inventoryItem) {  
console.log(inventoryItem);
};

这是我的州

.state('inventory.description',{
url:'/inventory/description/:id',
    views: {
        "descriptionview": {
            templateUrl: 'inventory/description.tpl.html',
            controller: 'DetailCtrl'
        }
    },
    data:{ pageTitle: 'DescriptionView'},
    resolve: {
        inventoryItem: function($stateParams, Inventory){
            return  Inventory.query({id: $stateParams.id});
    }
}
})

控制台检索数据

Resource {$promise: Object, $resolved: false, $get: function, $save: function, $query:        function…}
$promise: Object
$resolved: true
barcode: "11234"
count: 22
cover: "/media/http%3A/api.bos.lv/media/static/images/no-image_1.png"
created: "2014-03-07T11:07:18.184465"
description: "LG monitor description"
id: 2

1 个答案:

答案 0 :(得分:1)

我认为你可以这样做:

您可以在控制器中指定

$scope.toDisplay = inventoryItem;

并在您的模板中,将其添加到您要显示的位置:

{{toDisplay.barcode}}