After a bit if as struggle (I am new to Umbraco and AngulasJS) I think I have worked out how to set a default value to my new custom property editor by checking and updating $scope.model.value if it is empty or null eg
This will only set the default value on load if the value is currently empty ; therefore if someone deliberately empties the text box then saves the document, the next time they load the document, it will revert to the default. It would be better to only set the default on the first load. Is there any way of detecting a new document - either in Angular's own scope (I suspect it isn't aware of the document) or from Umbraco ie a flag that can be accessed to detect new a new document)
Rather than hard code the default, how can I add extra content to the custom editor (similar to the prevalues for dropdown lists) so every time I add the editor to a document type I type in the default at the same time?
Custom Property Editors default value
After a bit if as struggle (I am new to Umbraco and AngulasJS) I think I have worked out how to set a default value to my new custom property editor by checking and updating $scope.model.value if it is empty or null eg
HTML View ... ...
CONTROLLER JS angular.module("umbraco") .controller( "my.Controller", [ '$scope', function($scope){ $scope.setDefault = function(defaultText){ if($scope.model.value==''||$scope.model.value==null){ $scope.model.value=defaultText; } } } ] );
Questions :
Thanks!
is working on a reply...