krillebimbim krillebimbim - 4 years ago 71
HTTP Question

How do I retrieve the object details in angular?

I have tried to search for a solution to my problem but it seems my code should work. I have retrieved data from firebase and want to display it in my view.
The data object is shown in the developer console as being there when I am in the view in question.

My view:

<ion-view cache-view="false" ng-controller="PostCtrl">
<ion-nav-title>{{ viewname }}</ion-nav-title>
<ion-content class="has-header contentpane">

<div class="titlepane">
<h4 class="posttitle">
{{item.title}}
</h4>
<p class="categorytitle">
{{item.category}}
</p>
</div>

</ion-content>
</ion-view>


The controller:

firebaseApp.controller('PostCtrl', function ($scope, firebaseApi, $stateParams) {
'use strict';

// Create a name for the view to show as the title
$scope.viewname = 'Svampe';

// The stateParams is defined in the Services.js and defined in the scope here.
$scope.id = $stateParams.id;

// API call to the firebase for a specific post
firebaseApi.getSingle($scope.id).then(function (succ) {
$scope.item = succ;
console.log("Items", $scope.item);
}, function(err) {
console.log('Error: ', err);
});

});


Do you have any idea why the data is not showing in the view? I can see the object is retrieved successfully but it's not showing.

NNR NNR
Answer Source

Try this

{{item.data.title}}

{{item.data.category}}

Fiddle:

http://jsfiddle.net/B9RsQ/40/

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download