0
我正在爲Umbraco 7中的內容選取器實現一個控制器,在那裏我需要更改起始節點以匹配特定的內容節點。但文我加載了內容選擇器的頁面我收到一個錯誤說:
「無法讀取的未定義的屬性‘配置’」
關於這段代碼:
$scope.model.config.StartNodeId = 1083;
if ($scope.model.config.StartNodeId) {
options.startNodeId = $scope.model.config.StartNodeId;
}
我的整個控制器:
angular.module("umbraco").controller("UIOMatic.FieldEditors.Pickers.ContentController",
function ($scope, $routeParams, $http, dialogService, entityResource, iconHelper) {
function init() {
if (!$scope.setting) {
$scope.setting = {};
}
var val = parseInt($scope.property.value);
if (!isNaN(val) && angular.isNumber(val) && val > 0) {
$scope.showQuery = false;
entityResource.getById(val, "Document").then(function (item) {
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.node = item;
});
}
$scope.openContentPicker = function() {
var d = dialogService.treePicker({
section: "content",
treeAlias: "content",
multiPicker: false,
callback: populate
});
};
$scope.model.config.StartNodeId = 1083;
if ($scope.model.config.StartNodeId) {
options.startNodeId = $scope.model.config.StartNodeId;
}
$scope.clear = function() {
$scope.id = undefined;
$scope.node = undefined;
$scope.property.value = undefined;
};
function populate(item) {
$scope.clear();
item.icon = iconHelper.convertFromLegacyIcon(item.icon);
$scope.node = item;
$scope.id = item.id;
$scope.property.value = item.id;
}
};
if ($scope.valuesLoaded) {
init();
} else {
var unsubscribe = $scope.$on('valuesLoaded', function() {
init();
unsubscribe();
});
}
});
我試圖改變的開始節點ID爲1083,這就是我想要的,我可以打開內容選擇器,但它不會允許我保存更改。它也允許多選,我在配置對象中設置爲false。
這是筆者內容選擇器中的文件: http://uiomatic.readthedocs.io/en/stable/02.DefaultEditorViews/#content-picker
謝謝,我設法解決它! – Leth