首页 > 解决方案 > 如何在“保存并发布”之前更新自定义 Umbraco 数据类型中的 $scope.model.value?

问题描述

我目前正在为 Umbraco 7.11 开发自定义数据类型,我想$scope.model.value在用户单击“保存并发布”时更新文档保存和发布之前的内容。

我已经在Umbraco API 文档中搜索了我可以订阅的任何类型的钩子或事件,以实现这一点,但没有找到任何东西。

以下是角度的模拟数据类型控制器,显示了我想要实现的目标:

angular.module('umbraco')
.controller('MyDataType', ['$scope', function ($scope) {

    // I want to update the value of the data-type just before the 
    // document is published, by calling this function
    function onBeforeSaveAndPublish() {

        console.log('Run this code before the document is saved and published')

        // Example of what I would like to do before document is saved and published
        $scope.model.value = new Date().toString()
    }

    // Where to register onBeforeSaveAndPublish() ? Is this possible ?
}])

这可能吗,还是我应该重新考虑我的数据类型的设计?

标签: javascriptangularjsumbraco7

解决方案


推荐阅读