I'm currently working on developing an app using the Ionic Framework.
My goal is to retrieve data from an external JSON file by providing a token and parameter (1 for premium or 2 for basic).
The URL displays the data correctly, but I am struggling to understand how to fetch the data in my "pageCtrl".
I attempted following this guide
Unfortunately, when running the app, I only see 3 blocks without any actual data.
This is the code snippet I have in my controller.js:
// Controller for docs.
appControllers.controller('docsCtrl', function ($scope, $mdBottomSheet, $mdToast, $mdDialog, $http) {
$http.get('https://www.domain.com/api/document?__token=[the_token_added_on_code]&__idPortal=1').
success(function(data, status, headers, config) {
$scope.docs = data;
}).
error(function(data, status, headers, config) {
// log error
});
}); // End of docs controller.
Here's the HTML code:
<ion-view view-title="Documentos">
<!--dashboard section-->
<ion-content id="docs-content">
<div class="documentos padding">
<ion-list>
<ion-item ng-repeat="doc in docs" class="item-avatar">
<h2>{{doc.name}}</h2>
<p>{{doc.description}}</p>
<p>{{doc.created}}</p>
</ion-item>
</ion-list>
</div>
</ion-content><!--end dashboard section-->
</ion-view>
The URL returns the following data:
{"success":true,"return":{"totalItem":"33","totalPages":7,"pageSize":5,"itens":[{"id_document":"4760","name":"Teste","created":"02\/09\/2015 16:57:00","id_type":"108","type":"Documento Teste","description":"Documento"},{"id_document":"4722","name":"Ata de assembleia 08\/2015","created":"31\/08\/2015 17:32:55","id_type":"3","type":"Ata da assembl\u00e9ia","description":null},{"id_document":"4400","name":"Regimento","created":"04\/08\/2015 16:47:30","id_type":"108","type":"Documento Teste","description":"Regimento interno "},{"id_document":"4261","name":"ATA da AGE em 18\/09","created":"26\/07\/2015 22:22:39","id_type":"3","type":"Ata da assembl\u00e9ia","description":null},{"id_document":"2964","name":"Novo regimento playground","created":"05\/05\/2015 14:30:17","id_type":"91","type":"Regimento Interno","description":"Segue novo regimento playground"}]}}
Thank you in advance for your assistance.