Skip to content

Instantly share code, notes, and snippets.

@mattbrailsford
Created February 23, 2018 08:28
Show Gist options
  • Save mattbrailsford/7eed108850c2858588e0245f0320fb2a to your computer and use it in GitHub Desktop.
Save mattbrailsford/7eed108850c2858588e0245f0320fb2a to your computer and use it in GitHub Desktop.
Example Umbraco property editor code for writing to the model.value and listening for changes without using an angular watcher
//here we declare a special method which will be called
// whenever the value has changed from the server
$scope.model.onValueChanged = function (newVal, oldVal) {
// Model value changed so update UI
updateUi()
};
var unsubscribe = $scope.$on("formSubmitting", function () {
// Write data back to the model.value
$scope.model.value = ...
});
$scope.$on('$destroy', function () {
unsubscribe();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment