Utilizing a directive with two modes, edit and preview, multiple times in my codebase.
function () {
return {
restrict: "E",
scope : {
model : '='
},
[...]
controller : function($scope, $element){
$scope.switchToEdit = function(){
$scope.isEditMode = true;
}
$scope.switchToPreview = function(){
$scope.isEditMode = false;
}
}
}}
When switching to edit mode on an element, any other element already in edit mode should revert back to preview mode. How can this be achieved?