I am making a listing and want to pass the values of a model to the algebra script that is in the view.
Model:
function getAllDisplayable_all()
{
$this->db->select('id_menu, nome, descricao, preco, foto');
$result = $this->db->get('menus');
return $result->result();
}
script:
<script>
angular.module('myApp', []).controller('namesCtrl', function($scope) {
$scope.names = [
'teste',
//quero passar as variaveis php para aqui
];
});
</script>
html listing:
<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 ng-repeat="x in names | filter:test">
<td>{{ x }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
Normally I have gone fetching the data as follows:
<?php foreach ($list as $menus): ?>
<div class="pr">
<?php echo $menus->nome?>
</div>
<?php endforeach ?>
But this time I need to use angular.js. Thank you.