1
I want to make a table in which the td
are the name and price of an item. And I want the user to be able to search for an item by its name through a input
. This is already working. But the table is not appearing as I want, as I insert the array into a single td
and I only get one row of items, while I want a column.
I have so:
But I want the names to appear in column and not in line. My code is:
<div class="container">
<form class="navbar-form" role="search">
<div ng-app="myApp" ng-controller="namesCtrl">
<p>Pesquise um menu</p>
<p><input type="text" ng-model="test"></p>
</form>
<div class="row">
<div class="table-responsive">
<table class="table table-hover">
<thead>
<tr>
<th>Nome</th>
<th>Preço</th>
</tr>
</thead>
<tbody id="myTable">
<tr>
<td ng-repeat="x in names | filter:test">{{ x }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
script:
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'Jani',
'Carl',
'Margareth',
'Hege',
'Joe',
'Gustav',
'Birgit',
'Mary',
'Kai'
];
});
</script>