Here is the directive
directives.directive("unitDirective", function(){
return {
templateUrl: "../html/directives/unitDir.html"
}
});
Here is the template
<div ng-repeat="unit in addUnit()">
<label class="item item-input">
<span class="input-label">Unit {{unit+1}}</span>
<input type="number" placeholder="enter estimated monthly rent" ng-model="units.price[$index]">
</label>
</div>
Here is where I would like the button to be
<ion-view>
<ion-content>
<unit-directive></unit-directive>
<button class="button buttomn-assertive">Confirm</button>
</ion-content>
</ion-view>
Here is my controller:
controllers.controller("unitsCtrl", function($scope, $stateParams){
$scope.units = {
price: [1,2]
}
$scope.addUnit = function(){
var dummyArray = [];
for(var i =0; i < $stateParams.units; i++){
dummyArray[i] = i;
}
return dummyArray;
};
$scope.calculate= function(){
//how do I access the array of units prices here?
}
});
Basically, i used cordovadialog plugin to ask how many units they want to create and then i made a dummy array with the number provided and used it for ng-repeat. Now, I have to take in all the inputs and store them in an array and I am stuck. Any general direction to any other possible duplicate question, a solution or documentation/tutorial would be highly appreciated.