My controller contains an array. Each item in the array is a directive with template. How do I get value to directive when I push a new one? I want to send ID to directive when I push new item.
Controller
(function () {
'use strict';
angular
.module('app')
.controller('dashboardController', dashboardController);
dashboardController.$inject = ['$scope', '$timeout', '$state', 'apiService'];
function dashboardController($scope, $timeout, $state, apiService) {
$scope.newCMP = newCMP;
$scope.openCMPArray = [];
function newCMP() {
$scope.openCMPArray.push({id:"3"});
}
}
})();
Directive
(function () {
'use strict';
angular
.module('app')
.directive('gpCmpForm', cmpForm);
function cmpForm() {
return {
scope: {
id: '=id' //I've tried doing a lot of different mapping here
},
restrict: 'A',
templateUrl: '/app/views/cmpForm.html',
controller: function ($scope) {
$scope.test = "342";
}
}
};
})();
How does the directive get the ID when it is created?