Advertisement
Guest User

Ionic - Wordpress rest api

a guest
Nov 25th, 2015
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.55 KB | None | 0 0
  1. //Controller
  2.  
  3. .controller('ProgramacaoCtrl', function ($scope, $http) {
  4.  
  5. //Gets the list of the taxonomy
  6. $http.get('http://104.236.99.94/wp-json/wp/v2/terms/data').then(
  7.  
  8. function(data){
  9. $scope.dias = data.data;
  10.  
  11. }, function(err){
  12. console.log(err);
  13. })
  14.  
  15. // Gets the custom post ty
  16. $http.get('http://104.236.99.94/wp-json/wp/v2/atividade?filter[terms]=data&filter[meta_key]=horario_inicio&filter[order]=ASC&filter[orderby]=meta_value_num').then(
  17.  
  18. function(data){
  19. $scope.atividades = data.data;
  20.  
  21. }, function(err){
  22. console.log(err);
  23. })
  24. });
  25.  
  26.  
  27. //Views template
  28.  
  29. //It lists the posts inside the taxonomy, but it shows all the posts, intead of showing only the posts in the taxonomy.
  30.  
  31. <ion-view view-title="Programação">
  32. <ion-content class="padding">
  33.  
  34. <div class="list list-inset">
  35. <label class="item item-input">
  36. <i class="icon ion-search placeholder-icon"></i>
  37. <input type="text" placeholder="Busca" ng-model="busca">
  38. </label>
  39. </div>
  40.  
  41. <div ng-repeat="dia in dias">
  42. <h2 class="title">{{dia.name}} </h2>
  43. <ion-list>
  44. <ion-item ng-repeat="atividade in atividades | filter:busca" href="#">
  45. <h2 ng-bind-html="atividade.title.rendered">{{ atividade.title}}</h2>
  46. <p>
  47. <span>{{ atividade.acf.horario_inicio}} - {{ atividade.acf.horario_termino}}</span> -
  48. <span> {{ atividade.acf.local}}</span>
  49. </p>
  50. </ion-item>
  51. </ion-list>
  52. </div>
  53.  
  54. </ion-content>
  55. </ion-view>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement