javascript - How to get data from external JSON with Ionic? -


currently i'm developing app using ionic framework.

i need data external json file using token , parameter (1 premium or 2 basic)

the url display data correctly, don't understand how data "pagectrl".

i try http://fdietz.github.io/recipes-with-angular-js/consuming-external-services/requesting-json-data-with-ajax.html

but in app see 3 blocks without data

i'm using code on controller.js

// controller of 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. 

on html:

<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> 

finally, url return 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"}]}} 

in advance, thank's support

if return data correctly have items attr itens

 $scope.docs = data.itens; 

so please log data console.log(data) find properties in object , navigate {status: true, return: { .. itens:[] }}

$scope.docs = data.return.itens 

Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -