Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Tim C 161 posts 528 karma points
    May 13, 2016 @ 10:20
    Tim C
    0

    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 :

    1. Is this the best way to achieve this?
    2. 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)
    3. 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?

    Thanks!

Please Sign in or register to post replies

Write your reply to:

Draft