Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="{{item.url}}" class="item item-avatar" ng-repeat="item in restocks | reverse" ng-if="!$first">
- <img src="https://lukemil.es/sup-images/mobile/{{item.id}}.jpg">
- <h2>{{item.name}}</h2>
- <p>{{item.colors}}</p>
- </a>
- </div>
- angular.module('restocks', ['ionic'])
- .service('restockAPIservice', function($http) {
- var restockAPI = {};
- restockAPI.getRestocks = function() {
- return $http({
- method: 'GET',
- url: 'https://myurl/api/restocks.php'
- });
- }
- return restockAPI;
- })
- .filter('reverse', function() {
- //converts json to JS array and reverses it
- return function(input) {
- var out = [];
- for(i in input){
- out.push(input[i]);
- }
- return out.reverse();
- }
- })
- .controller('itemController', function($scope, restockAPIservice) {
- $scope.restocks = [];
- $scope.sortorder = 'time';
- $scope.doRefresh = function() {
- $('#refresh').removeClass('ion-refresh');
- $('#refresh').addClass('ion-refreshing');
- restockAPIservice.getRestocks().success(function (response) {
- //Dig into the responde to get the relevant data
- $scope.restocks = response;
- $('#refresh').removeClass('ion-refreshing');
- $('#refresh').addClass('ion-refresh');
- });
- }
- $scope.doRefresh();
- });
- TypeError: Cannot call method 'querySelectorAll' of undefined
- at cancelChildAnimations (http://localhost:8000/js/ionic.bundle.js:29151:22)
- at Object.leave (http://localhost:8000/js/ionic.bundle.js:28716:11)
- at ngRepeatAction (http://localhost:8000/js/ionic.bundle.js:26873:24)
- at Object.$watchCollectionAction [as fn] (http://localhost:8000/js/ionic.bundle.js:19197:11)
- at Scope.$digest (http://localhost:8000/js/ionic.bundle.js:19300:29)
- at Scope.$apply (http://localhost:8000/js/ionic.bundle.js:19553:24)
- at done (http://localhost:8000/js/ionic.bundle.js:15311:45)
- at completeRequest (http://localhost:8000/js/ionic.bundle.js:15512:7)
- at XMLHttpRequest.xhr.onreadystatechange (http://localhost:8000/js/ionic.bundle.js:15455:11) ionic.bundle.js:16905
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement