First of all, I have to say that is my first time posting on StackOverflow.. So if I post on the wrong area, sorry.

I'm beginning with angularjs, and I'm struggling into two points. 1st I've to create a connection with my mysql, witch i wasn't able until now.. 2nd I've to display the content into the HTML page.

I'm using the following code, witch includes the app.js, page.html and data.json (I'll change that later to php if I'm allowed to.) The app.js seems to work fine, but the view (page.html) isn't display any data..

App.js

    app.controller('PatientListCtrl', ['$scope', '$http', function ($scope, $http) {
    $http.get('patients.json').success(function (data) {
        $scope.patients = data;
    });
    $scope.orderProp = 'id';
}]);

patients.json

[
    {
        "id": 0, 
        "first_name": "John", 
        "last_name": "Abruzzi"
    }, 
     {
        "id": 1, 
        "first_name": "Peter", 
        "last_name": "Burk"
    }
]

Page.html

<!DOCTYPE html>
<html class="no-js" ng-app="app">

  <head>
    <meta charset="utf-8" />
    <title>AngularJS Plunker</title>
  </head>

  <body>

    <div data-ng-repeat="patient in patients">
        {{patient.id}}{{patient.last_name}}{{patient.first_name}}{{patient.SSN}}{{patient.DOB}}      
        <div>

    <script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>
    <script src="app.js"></script>

  </body>

</html>

Thanks for your attention.

share|improve this question
    
You call a "patients.json" file in your controller, but named it data.json in your exemple, is that normal ? – KCarnaille Dec 30 '15 at 14:02
    
My bad, the file actually is named patients.json. I'll edit my post. Thank you for the reminder :) – Fred. Dutra Dec 30 '15 at 14:07
up vote 1 down vote accepted

You have not define the controller in the view

<div ng-controller="PatientListCtrl" data-ng-repeat="patient in patients">
       <li> {{patient.id}} </li>
  <div>

Here is the working Fiddle

share|improve this answer
    
Sajeetharan thank you, but the page still blank... – Fred. Dutra Dec 30 '15 at 14:03
    
check my jsfiddle – Sajeetharan Dec 30 '15 at 14:04
    
man, I owe you one! Thank you a lot! – Fred. Dutra Dec 30 '15 at 14:06
    
@Fred.Dutra welcome, mark as answer if it had helped you – Sajeetharan Dec 30 '15 at 14:07
    
Be sure I'll! Although idk if I can (low points I guess). Give my 3 min and I'll find out :D – Fred. Dutra Dec 30 '15 at 14:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.