HTML:
<br/><button class="btn btn-primary" ng-disabled="enableCompare()" ng-click="on_compare_plateformes($item)">Comparer</button>
JS:
propertiesModule.controller('PropertiesComparePlateformesCtrl', ['$scope', 'compareService', '$routeParams', 'PropertiesService', 'ApplicationService', 'PlatformService', 'Page', function ($scope, compareService, $routeParams, PropertiesService, ApplicationService, PlatformService, Page) {
$scope.on_compare_plateformes = function () {
...
};
..
}]);
propertiesModule.directive('propertiesListCompare', ['compareService', function (compareService) {
return {
restrict: 'E',
scope: {
properties: '=',
propertiescible: '=',
application: '=',
applicationcible: '=',
undo: '=',
myselectref: '=',
myselectcible: '='
},
templateUrl: "properties/properties-list-compare.html",
link: function (scope, element, attrs) {
// scope.$watch("propertiescible", function () {
var unregister = scope.$watch('[properties, propertiescible]',function () {
...
}, true);
...
unregister();
}
};
}]);
How to rebind the $watcher when i click my button .?
I guess, by calling
unregister
function you want to unbind listener. But you should do it when the scope is being destroyed, not right after watcher has been set. So,