I'm using a directive with ng-repeat, which looks like this:
<new-tax-country
ng-repeat="newItem in data.company.extraTaxCountries track by $index"
ng-model="data.company.extraTaxCountries[$index]">
</new-tax-country>
I'm adding objects in the array according to the need, like this:
$scope.addTaxCountry = function() {
$scope.data.company.extraTaxCountries.push({});
}
On every click of the button, I'm adding a new empty object into the array, and also a new directive is created.
I need to bind the directive to the empty object, so that when I fill the fields inside the directive, those exist also in the previously empty object.
My directive so far looks like this:
(function() {
angular.module('account-form-client-de')
.directive("newTaxCountry", function(Countries) {
var options = {
restrict: 'E',
require: 'ngModel',
replace: true,
scope: {
},
link: function(scope, element, attrs, controller, $parent) {
},
templateUrl: 'template/directive/new-tax-country.html'
};
return options;
});
})();
And the html:
<div class="newtaxcountry">
<label for="new_taxid">
bla
</label>
<input name="new_taxid" ng-model="newTaxInnerScope.new_taxid">
</div>
How could I proceed so that every newItem in data.company.extraTaxCountries automatically inherits the properties of the newTaxInnerScope object that exists inside the directive?