So i have a group of input fields of location and description that i am repeating over with a show and hide button for the 2nd group
so my html:
<div ng-repeat="location in vm.locations" class="row">
<div class="form-group col-md-12">
<label for="location">Location</label>
<input type="text" class="form-control" name="location" ng-model="location.name">
<a class="pull-right" ng-click="vm.showLocationDetail()">Add Description</a>
</div>
<br>
<div ng-show="vm.showDetail" class="form-group col-md-12">
<textarea class="form-control" type="text" name="description" rows="5" ng-model="location.description"></textarea>
</div>
</div>
controller:
// toggle location details
vm.showLocationDetail = function() {
return vm.showDetail = !vm.showDetail;
}
right now if i have more than 1 field of locations and i click add description...every field shows the description input field.
How do i make it so that it only shows the relevant description field?
This is because you are using single variable to show and hide all the description field. Use location's some property to show or hide that.