1

I am pretty much new to angularjs and onsenUI and have been stuck on figuring out how to display data from the php url into my page...

here is my code

controller.js

angular.module('app').controller('CardController',['$scope','$http', function($scope, $http) {
        $http.get('http://sth.sth.sth.php')
            .success(function(data, status, headers, config) {
              $scope.cards = data.cards;

      })
      .error(function(error, status, headers, config) {
         console.log(error);
         console.log("Error occured");
      });

card.html

<div ng-controller="CardController">
    <ul >
        <li ng-repeat="item in cards track by $index">
          {{cards.title}}
          {{cards.id}}
        </li>
      </ul>
  </div>

I will be more than thankful if someone chip me a way to figure it out. Thanks

0

1 Answer 1

2

Instead of cards its should be item -

    <li ng-repeat="item in cards track by $index">
      {{item.title}}
      {{item.id}}
    </li>
Sign up to request clarification or add additional context in comments.

2 Comments

still its giving me this error... don't really have a token error, but it states that I do... SyntaxError: Unexpected token ( at Object.parse (native) at fromJson (localhost:3000/lib/angular/angular.js:1250:14) at defaultHttpResponseTransform
@boochoo console.log(data) from the server and check if its a valid JSON

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.