1
Hello!
In the form of html
I’ll tell you what:
<div class="container jumbotron" ng-controller="crudCtrl">
<form role="form">
<div class="form-group">
<label for="nome">Nome:</label>
<input type="text" class="form-control" ng-model="nome" id="">
</div>
<div class="form-group">
<label for="sexo">Sexo:</label>
<input type="text" class="form-control" ng-model="sexo" id="sexo">
</div>
<div class="form-group">
<label for="data">Data Nascimento:</label>
<input type="text" class="form-control" ng-model="dataNascimento" id="data">
</div>
<div class="form-group">
<label for="pais">País:</label>
<input type="text" class="form-control" ng-model="pais" id="pais">
</div>
<button class="btn btn-default" ng-click="Cadastrar()">Salvar</button>
</form>
</div>
And at the following angle:
var app = angular.module("crud", []);
app.controller("crudCtrl", function ($scope) {
$scope.Cadastrar = function(data) {
$scope.MostrarTabela = true;
$scope.nome = data.nome;
$scope.sexo = data.sexo;
$scope.datanasc = data.dataNascimento;
$scope.pais = data.pais;
}
});
It’s wrong the way I’m sending the data to the controller
?
As it presents the following error:
Cannot read Property 'name' of Undefined
I didn’t quite understand this "registration.name" way, doesn’t it work anymore using the date? and how do I insert into a table on Html5 through and display with ng-repeat?
– novato
@rookie edited my answer
– celsomtrindade
show!... the way I did, I put in several variables in Scope.. to display this in an ng-repeat I would have to put in a single variable of Scope and then "go through" it, right?
– novato
It would be the most practical way. It is also worth remembering that when creating several
$scope
it will generate an impact on performance (if passed to the view), so it is not the best option.– celsomtrindade