Apply for Zend Framework Certification Training

AngularJs





data.txt

[{
    "Name" : "Mahesh Parashar",
    "RollNo" : 101,
    "Percentage" : "80%"
 },{
    "Name" : "Dinkar Kad",
    "RollNo" : 201,
    "Percentage" : "70%"
},{
    "Name" : "Robert",
    "RollNo" : 191,
    "Percentage" : "75%"
},{
    "Name" : "Julian Joe",
    "RollNo" : 111,
    "Percentage" : "77%"
}]

ajaxlist.js

function studentController($scope,$http) {
    var url="data.txt";
    $http.get(url).success( function(response) {
                           $scope.students = response;
                        });
}

index.html

<html>
<head>
<title>Simple Angularjs To Call File data</title>
<style>
    table, th , td {
      border: 1px solid grey;
      border-collapse: collapse;
      padding: 5px;
    }
    table tr:nth-child(odd) {
      background-color: #f2f2f2;
    }
    table tr:nth-child(even) {
      background-color: #ffffff;
    }
</style>

<script src="angular.min.js"></script>
<script src="ajaxlist.js"></script>

</head>
<body>
<h2>Simple Angularjs To Call File data</h2>
<div ng-app="" ng-controller="studentController">
<table>
   <tr>
        <th>Name</th>
        <th>Roll No</th>
        <th>Percentage</th>
   </tr>
   <tr ng-repeat="student in students">
        <td></td>
        <td></td>
        <td></td>
   </tr>
</table>
</div>
</body>
</html>                             

< Angularjs Form Data Submit Using Php Mysql Example How to submit post data in angularjs Using php >



Ask a question



  • Question:
    {{questionlistdata.blog_question_description}}
    • Answer:
      {{answer.blog_answer_description  }}
    Replay to Question


Back to Top