To pinpoint the bug I have, I created two instances of the same directive in my view :
<criterion-news
state="ctrl.state">
</criterion-news>
<criterion-news
state="null">
</criterion-news>
The first gets its state from containing controller, the second one is told explicitely to have no state.
Each instance of the directive consists of a tree-based list, and the purpose of the directive is to display this list and manage the item selection behaviour.
When I click in the UI of the second directive, the state of the first directive is updated : when I check a checkbox in the second instance, the checkbox of the corresponding item in the first instance gets checked. It seems to me that, as isolated-scopes are created in each instance, and as I passed "null" to the second directive, no data should be shared between the two instances. Here is the structure of the directive :
"use strict";
(function() {
angular
.module("z360m.target-list")
.directive("criterionNews", function() {
return {
restrict: "E",
scope: {
"state": "="
},
bindToController: true,
templateUrl: "my template url",
controllerAs: "ctrl",
controller: function() { ... }
};
});
})();
Is there something wrong in it ?
EDIT : My directive contains checkboxes, which are identified by a functional id. The problem was that the same ids were duplicated in both instances. I added a random-generated directive instance id in my checkbox ids, and now it works like a charm : my states are independant.