We have next directive implemented:
angular.module('app', [])
.directive('dIsolatedWorks', function() {
return {
scope: {
prop: '='
},
template: '<span>{{name}}: {{prop}}</span>',
link: function(scope) {
scope.name = 'isolated';
scope.prop = 'link';
}
};
})
.directive('dIsolated', function() {
return {
scope: {
prop: '@'
},
template: '<span>{{name}}: {{prop}}</span>',
controller: function($scope) {
$scope.prop = 'controller';
},
link: function(scope) {
scope.name = 'isolated';
scope.prop = 'link';
}
};
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app">
<div d-isolated-works prop="attribute"></div>
<div d-isolated prop="attribute"></div>
</div>
Actually during implementation I was sure that assignment to the scope.prop field will change the variable and it will be displayed as 'link', not 'attribute'.
But currently we see that the real value will be isolated: attribute.
However it can be simply fixed by changing string assignment to object assignment.
Can you explain such behavior?