Is angular region binding and (ampersand) one-time binding? I see that this is called one-way binding, but is it also one-time?
Let's say I have:
<my-custom-directive data-item="item" />
And my directive is declared as follows:
.directive('myCustomDirective', [
'$log', function ($log) {
return {
restrict: 'E',
templateUrl: '/template.html',
scope: {
dataItem: '&'
}
controller: function ($scope) {
}
}])
The reason I ask if the snap is a one-time binding is because it looks like what I'm observing. If itemthe parent area is updated, then the directive is not updated.
Am I saying correctly that binding is one time?
To achieve what I want, where the directive stores a copy without affecting the element of the parent object - I did this:
.directive('myCustomDirective', [
'$log', function ($log) {
return {
restrict: 'E',
templateUrl: '/template.html',
scope: {
dataItemOriginal: '='
},
link: function ($scope) {
$scope.$watch('dataItemOriginal', function () {
$scope.dataItem = window.angular.copy($scope.dataItemOriginal);
});
},
controller: function ($scope) {
}
}])
Is this right or is there a better way?