2
This is guys Blz?!
I’m new to Angularjs.
I’m developing a form but I can’t do ng-model abstraction. Follow the code below for better understanding.
<- JS ->
/* CONFIGURAÇÃO DO FORM */
$scope.cfgForm = {
item: {
field: ["nome", "idade", "funcao"],
headers: ["Nome", "Idade", "Função"],
icon: ["person", "date_range", "business_center"]
}
};
/* DADOS */
$scope.clientes = [
{nome: "Pablo Mendoça", idade: 25, funcao: "Estagiário"},
{nome: "Ricardo Leite", idade: 41, funcao: "Diretor"},
{nome: "Francisco Motta", idade: 35, funcao: "Gerente de Contas"}
];
/* FUNÇÕES */
/* ADICIONAR CLIENTE */
$scope.addCliente = function(cliente){
console.log(cliente);
};
<- HTML ->
<div>
<!--{{cfgForm.item.field[k]}}-->
<md-input-container md-no-float class="md-block" ng-repeat="(k,field) in cfgForm.item.field">
<label>{{cfgForm.item.headers[k]}}</label>
<md-icon><i class="material-icons" >{{cfgForm.item.icon[k]}}</i></md-icon>
<input ng-model="cliente.field" type="text">
<!--{{cliente.field}}-->
</md-input-container>
<!--Botões de ação do Card-->
{{cliente.field}}
<md-card-actions layout="row" layout-align="end center">
<md-button class="md-icon-button" ng-click="addCliente(cliente)">
<i class="material-icons" >add_box</i>
<md-tooltip md-direction="left">
Adicionar
</md-tooltip>
</md-button>
</md-card-actions>
</div>
</md-card-content>
Well, what happens is that when I put the add button in ng-repeat it abstracts the data and shows in the console, however it cannot repeat, IE, the button should stay out of ng-repeat. As I am shown above.
In this section of the code for example:
{{client field.}}
When I remove the comment in 1º {{client.field}} it makes the right bind. However the 2º {{client.field}} that is already outside ng-repeat does not. and what I need is just for that to do, so I can pass the data on ng-click that is outside ng-repeat.
I’d like the help!
Before offering a definitive answer. I identified that Voce has a list of customers on top within a table. And below What do you want to show the information of a particular client? How does the code know which client it will display below? Either Voce needs to provide this through a click, or at least the controllers need to start by telling which customer is selected to display the data below.
– Roger Barretto