我已经创建了一个属性编辑器,我已经设置了一个文档来显示这个属性,如下所示:
我仍然无法弄清楚如何在首页上显示文字。我设法显示我添加到文档中的另一个名为box的属性
以下是我的控制器的外观:
angular.module("umbraco").controller("mytext",
function ($scope) {
// do code here
});
以下是mytext.html的外观:
<div ng-controller="mytext" class="mytext">
<h2>Hellooooooo!</h2>
<!--<input type="text" ng-model="model.value" />
ng-model="model.value" />-->
<div class="display"><h2>Hellooooooo!</h2></div>
</div>
这就是我的模板的样子:
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.MyHelooo>
@using ContentModels = Umbraco.Web.PublishedContentModels;
@{
Layout = "Master.cshtml";
}
@CurrentPage.Name
@CurrentPage.Hejhej
@CurrentPage.box
<p>All your bases</p>
最后这是我的package.manifest的样子:
{
"propertyEditors": [
{
"alias": "MyText",
"name": "My text",
"hideLabel": false,
"valueType": "JSON",
"editor": {
"view": "~/App_Plugins/MyText/mytext.html"
}
}
],
"javascript": [
"~/App_Plugins/MyText/mytext.controller.js"
],
"css":[
"~/App_Plugins/MyText/mytext.css"
]
}
编辑: 我用Joniff的答案制作了一个这样的控制器:
angular.module("umbraco").controller("mytext",
function ($scope) {
$scope.value = 'Helloooooooooooo!';
});
要使其工作,我必须使用CTRL + SHIFT + DELETE清除浏览器的缓存。 我还必须确保我在调试模式下运行Visual Studio,但是当你不知道什么是错的时候我会感到沮丧。
答案 0 :(得分:1)
从发布的确切代码中,您已经注释掉了将mytext.html中的model.value实际设置为值的代码。这确实需要设置为某些内容,否则,您的新属性类型在前端没有输出值。
如果您想对您的属性进行硬编码以始终显示'Helloooooooooooo!'
怎么样?angular.module("umbraco").controller("mytext",
function ($scope) {
$scope.value = 'Helloooooooooooo!';
});
或
<div ng-controller="mytext" class="mytext" ng-init="model.value='Hellooooooo'">
<h2>Hellooooooo!</h2>
<div class="display"><h2>Hellooooooo!</h2></div>
</div>
但是,为什么不使用输入控件来编辑model.value,比如
<div ng-controller="mytext" class="mytext">
<input type="text" ng-model="model.value" />
</div>
最终,我不确定您要实现的目标,因为您发布的代码与标签做的工作相同, A)Umbraco已经存在作为房产类型和 B)没有输入或输出,就像你的版本一样。