I m trying to create arrays dynamically on click by calling showItem() function.However,the array created is empty.On calling showSubCat(); I am adding items to the array created through showItem().
<div class="form-group" ng-repeat="notice in notices_main">
<div>
<input type="button" value="addSubcat" ng-click="showSubCat($index);"></input>
</div>
<!--i m not able to address the array-->
<div class="col-sm-8" ng-repeat="id in subCatArray{{index}}">
<label class="control-label">simple input</label>
<input type="text"></input>
</div>
</div>
<input type="button" value="addItem" ng-click="showItem();"></input>
js code
$scope.showSubCat = function(index) {
var newIndex = index + 1;
var tempName1 = "subCatArray"+newIndex;
var newIndex2 = $scope[tempName1].length + 1;
//m pushing elemnts in subCatArray1 or subCatArray2....and so on based on the index passed.
$scope[tempName1].push({'id':newIndex2});
}
$scope.showItem = function() {
var newNodeIndex = $scope.notices_main.length + 1;
var tempName1 = "subCatArray"+newNodeIndex;
//array created would be subCatArray1 for the first time..and so on.
$scope[tempName1] = [];
$scope.notices_main.push({'notice':'noticeModel'+newNodeIndex});
$scope.notices.push('noticeModel'+newNodeIndex);
}