I'm having a hard time creating a loop with ng-repeat
, no angle. Next ... I wanted to create tags
for every projeto
I add, eg:
Seethatyoucanaddmoretagsandthereisalsoatextattheendthataddsanewproject,calledAddProjeto
,totheclicked
THE PROBLEM : When I type a text for the projeto1
tag it is inscribed at the same time in the projeto2
tag! I guess this is because of {{tag.taagscliente}}
, which is the same for each project. How do I make this loop, without there being this conflict, say separate tags for each project? Project code below:
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script><divng-controller="dash">
<form action="">
<div class="col-3">
<div class="repeat" ng-repeat="projeto in clientes">
<label for="">Pasta Projeto</label>
<input type="text" name="projetos_cliente[]" ng-model="projeto.projetoscliente">
<label for="">Tags</label>
<div class="tags" ng-repeat="tag in taags">
<input type="text" name="tag_cliente[]" ng-model="tag.taagscliente">
<div class="del" ng-click="delTag($index)">-</div>
</div>
<div class="add" ng-click="addTag()">+</div>
</div>
<div class="clearfix"></div>
<div class="addx" ng-click="add()">Add Projeto</div>
</div>
</form>
</div>
ANGULAR:
var app = angular.module('app', ['ngTagsInput']);
app.controller('dash', function($scope, $http){
$scope.clientes = [{'text': 'Digite o projeto'}];
$scope.add = function () {
$scope.clientes.push({
projetoscliente:""
});
};
$scope.del = function (index) {
$scope.clientes.splice(index, 1);
};
$scope.taags = [{'text': 'Digite o projeto'}];
$scope.addTag = function () {
$scope.taags.push({
tagscliente:""
});
};
$scope.delTag = function (index) {
$scope.taags.splice(index, 1);
};
});