自定义属性编辑器返回对象Umbraco

时间:2018-01-16 09:11:12

标签: javascript asp.net razor umbraco umbraco7

我正在尝试在Umbraco中创建自定义属性编辑器。

Package.manifest

{
    propertyEditors: [
        {
            alias: "Notification Ribbon",
            name: "Notification Ribbon",
            editor: {
                view: "~/App_Plugins/NotificationRibbon/NotificationRibbon.html"
            }          
        }
    ],
    javascript: [
        '~/App_Plugins/NotificationRibbon/NotificationRibbon.controller.js'
    ]
}

并在我的控制器中

angular.module("umbraco").controller("NotificationRibbon.Controller", function($scope) {
    $scope.opennotification = function() {

        if (!$scope.control) {
            $scope.control = {}
        }
        if (!$scope.model) {
            $scope.model = {}
        }


        $scope.overlay = {
            title: "Nottification ribbon",
            view: "/ultradata/Views/common/overlays/notificationribbon/notificationribbon.html",
            rteeditor: $scope.model.value.rteeditor,
            NotifyLinkClass: $scope.model.value.NotifyLinkClass,
            Location: $scope.model.value.Location,
            ButtonValue: $scope.model.value.editModel,
            show: true,
            submit: function(model) {
                $scope.overlay.show = false;
                $scope.overlay = null;
                $scope.model.value = {};
                $scope.model.value.rteeditor = model.rteeditor.value;
                $scope.model.value.NotifyLinkClass = model.NotifyLinkClass;
                $scope.model.value.Location = model.Location;
                $scope.model.value.ButtonValue = model.ButtonValue;

            },
            close: function(oldModel) {
                $scope.overlay.show = false;
                $scope.overlay = null;
            }
        }

    }

});

属性编辑器值在服务器上存储如下:

{
        "id": 19151,
        "alias": "not",
        "value": {
            "rteeditor": "<p>fghfhfghfgh</p>"
        }
    }

当我尝试获取值并在Razor代码中显示通知文本值

<div class="gayaaa">@Umbraco.Field("not")</div>

结果返回屏幕中的整个对象

enter image description here

0 个答案:

没有答案