I want to make a table where td
is the name and price of an item. And I want the user to be able to search for an item by its name through input
. This is already working. But the table is not showing up as I want, because I enter the array in a single td
and I only have one row of items, whereas I want a column.
I have this:
ButIwantthenamestoappearinacolumn,notinaline.Mycodeis:
<divclass="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>