1
I’m making a list and I want to pass the values of a model to the algular 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 to fetch 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.
Please avoid long discussions in the comments; your talk was moved to the chat
– Maniero