ng-repeat issue creating a table

Hi:

I am not able to create a table from ng-repeat data:

<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.\
js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">

<script>
var app = angular.module('myApp',[]);
app.contoller('myCtrl', function($scope){

$scope.flights=[
{no:'DL 123', from:'SFO', to:'DEN', starttime:'7 AM', reaching:'9 AM' Duration:\
'2h', price:'100 dollars'},
{no:'UA 123', from:'SFO', to:'DEN', starttime:'7 AM', reaching:'9 AM' Duration:\
'2h', price:'100 dollars'},
{no:'VX 123', from:'SFO', to:'DEN' starttime:'7 AM', reaching:'9 AM' Duration:'\
2h', price:'100 dollars'}
];
}
</script>

<table ng-show="myVar" ng-controller="myCtrl">
  <tr ng-repeat="x in flights">
    <td>{{x.no}}</td>
    <td>{{x.from}}</td>
    <td>{{x.to}}</td>
    <td>{{x.starttime}}</td>
    <td>{{x.reaching}}</td>
    <td>{{x.Duration}}</td>
    <td>{{x.price}}</td>
  </tr>
</table>
</body>
</html>

Open in new window


Look forward to your comments.

Best Regards

Sunnybrad
sunnybradAsked:
Who is Participating?
 
Jan LouwerensSoftware EngineerCommented:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<body ng-app="myApp">

<table ng-controller="myCtrl">
<tr ng-repeat="x in flights">
  <td>{{x.no}}</td>
  <td>{{x.from}}</td>
  <td>{{x.to}}</td>
  <td>{{x.starttime}}</td>
  <td>{{x.reaching}}</td>
  <td>{{x.Duration}}</td>
  <td>{{x.price}}</td>
  <td>{{x.Name}}</td>
  <td>{{x.Country}}</td>
</tr>
</table>

<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function($scope) {
  $scope.flights = [
    {no:'DL 123', from:'SFO', to:'DEN', starttime:'7 AM', reaching:'9 AM', Duration:'2h', price:'100 dollars'},
    {no:'UA 123', from:'SFO', to:'DEN', starttime:'7 AM', reaching:'9 AM', Duration:'2h', price:'100 dollars'},
    {no:'VX 123', from:'SFO', to:'DEN', starttime:'7 AM', reaching:'9 AM', Duration:'2h', price:'100 dollars'}
  ]
});
</script>

</body>
</html>

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.