0
Good morning guys, could anyone help me, I need to take the value of the index variable from the angular to a small php block, to do the removal of it in the database.
The way it is I can’t, gives an error in the $Cope method.
ERROR:
<script type="text/javascript">
var myApp = angular.module('app', []);
myApp.controller('alunosCad', ['$scope', function ($scope) {
$scope.alunos = [
<?php
$alunosDataBase = DaoAluno::selectAll();
$count = count($alunosDataBase);
$i = 0;
foreach ($alunosDataBase as $alunosCad) {
if($i === ($count - 1)){
echo '{codigo: "'.$alunosCad->getId_aluno().'", nome: "'.$alunosCad->getNm_aluno().'", email: "'.$alunosCad->getMail_aluno().'"}';
}else{
echo '{codigo: "'.$alunosCad->getId_aluno().'", nome: "'.$alunosCad->getNm_aluno().'", email: "'.$alunosCad->getMail_aluno().'"},';
}
$i+=1;
}
?>
];
$scope.remover = function(index){
$scope.alunos.splice(index, 1);
<?php
$index = "<script>document.write(index)</script>";
$aRemover = $alunosDataBase[$index];
DaoAluno::delete($aRemover->getId_aluno());
?>
};
}]);
</script>
Dude you’re doing it wrong, you don’t use php code in the middle of Angular. You will have to take the database data and return in JSON format, usually this request is made by REST.
– Rafael
Ulysses, do not post pictures of your code. Copy and paste your own code here as text. And use Stackoverflow’s own tool to format the code.
– Rubico
All right. Thank you..
– Ulisses Gimenes