I have two tables: site
and ip
.
site
: site_id,name
ip
: ip_id,site_id,ip_adress
I have to show a list of ip_adress
of a site.
html
<div class="form-group" style="margin-bottom: 0px;">
<label class="col-sm-6 control-label">
<button style="margin-bottom:5px;" ng-click="addIp($index)">
<span class="glyphicon glyphicon-plus"></span>
</button>
</label>
<div class="col-sm-6">
<ul style="list-style-type: none">
<li ng-repeat="ip in site.ips track by $index">
<div class="input-group" >
<input type="text" class="form-control input-sm" name="ip_adress" style="display: inline;" ng-model="ip.ip_adress" required />
<div class="input-group-addon">
<i class="glyphicon glyphicon-remove-circle" ng-click="removeIp(site, ip, $index)"></i>
</div>
</div>
</li>
</ul>
</div>
</div>
JavaScript
$scope.addIp = function(index){
$scope.sites[index].ips[index].ip_adress.push("");
}
It throws this error:
$scope.sites[index].ips[index].ip_adress.push is not a function
Ips is a Set of Ip object, and ip_adress is a String. How can i resolve this ?
You should push to your array like: $scope.sites[index].ips.push(<here_goes_your_object_with_ip_string>);
if ips
is an array