* setup watch, to ensure model value is reflected across variants in splitview. * unsubscribe watch Co-authored-by: Niels Lyngsø <nsl@umbraco.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
function booleanEditorController($scope) {
|
||||
|
||||
// Setup the default config
|
||||
// This allow to overwrite the configuration when property editor is re-used
|
||||
// This allow to overwrite the configuration when property editor is re-used
|
||||
// in e.g. third party packages, dashboard or content app. For example when using umb-property-editor.
|
||||
// At the moment this use "1/0" as default for "truevalue" and "falsevalue", but allow "True/False" as well.
|
||||
// Maybe sometime later we can make it support "Yes/No" or "On/Off" as well similar to ng-true-value and ng-false-value in Angular.
|
||||
@@ -55,6 +55,13 @@ function booleanEditorController($scope) {
|
||||
setupViewModel();
|
||||
};
|
||||
|
||||
// If another property editor changes the model.value we want to pick that up and reflect the value in this one.
|
||||
var unsubscribe = $scope.$watch("model.value", function(newVal, oldVal) {
|
||||
if(newVal !== oldVal) {
|
||||
setupViewModel();
|
||||
}
|
||||
});
|
||||
|
||||
// Update the value when the toggle is clicked
|
||||
$scope.toggle = function(){
|
||||
setDirty();
|
||||
@@ -68,5 +75,9 @@ function booleanEditorController($scope) {
|
||||
setupViewModel();
|
||||
};
|
||||
|
||||
$scope.$on('$destroy', function () {
|
||||
unsubscribe();
|
||||
});
|
||||
|
||||
}
|
||||
angular.module("umbraco").controller("Umbraco.PropertyEditors.BooleanController", booleanEditorController);
|
||||
|
||||
Reference in New Issue
Block a user