I'm trying to generate a new form when an item is pushed into an array. The form is always the same, it just increases by one the conditional count.
Something like this:
<span ng-show="companydata.selectedloc.length == 0">
<div angucomplete-alt id="ex1"
selected-object="selectedLocation"
></div>
</span>
<span ng-show="companydata.selectedloc.length == 1">
<div angucomplete-alt id="ex1"
selected-object="selectedLocation"
></div>
</span>
<span ng-show="companydata.selectedloc.length == 2">
<div angucomplete-alt id="ex1"
selected-object="selectedLocation"
></div>
</span>
Every code block pushes an item into companydata.selectedloc on select (it's an autocomplete select input).
Here's the JS function:
$scope.selectedLocation = function(selected){
$scope.companydata.selectedloc.push(selected)
}
Being always the same code block, is there some way more elegant to do that than increasing the condition manually and adding as many code blocks as necessary (let's say to a max of 10)?
ng-repeat: docs.angularjs.org/api/ng/directive/ngRepeatcompanydata.selectedlocand the number of inputs, so they seem highly related. The guts of the ng-repeat html do NOT have to pertain to the item that is being repeated over, so based on your html exaple, it would be very straightforward.