0x6B6F77616C74 0x6B6F77616C74 - 3 years ago 130
AngularJS Question

Cannot make dynamic two column table

I want to have a table with headers and data dynamically loaded from object of two arrays. Unfortunately, these rows aren't displayed.


<div ng-controller="MyCtrl">
<tr ng-repeat="inout in inoutContainer track by $index">
<td>{{ inout.input_vector[$index] }}</td>
<td>{{ inout.output_vector[$index] }}</td>

var myApp = angular.module('myApp',[]);

//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});

function MyCtrl($scope) {
$scope.inoutContainer = {input_vector: ["0.0","0.0"], output_vector: ["0.0","0.0"]};
$scope.name = 'Superhero';

Answer Source

I managed to figure out a way to make it work -- you had a number of syntax errors that angularJS didn't understand


Basically I simplified the angularJS code

  • then added the ng-app directive to the container div

  • removed the track by $index part of the ng-repeat directive,

  • and finally added the myApp.controller() declaration.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download