Hi currently i am implementing a custom dropdown list for a macro and i have been reading and understanding the following blog : https://bii.github.io/umbraco/mvc/angular/2016/06/20/extending-umbraco-with-a-custom-property-editor.html
I have been able to create a new customer macro type but the selected answer is not being saved when you use the macro.
ColourClassPicker.controller.js
angular.module('umbraco').controller('ColourClassPicker.controller',
function ($scope, $filter) {
$scope.onLoad = function () {
$scope.Colours = [
{ id: '1', colour: 'purple-dark' },
{ id: '2', colour: 'yellow, pink' }
];
$scope.selectedColour = $filter('getByValue')($scope.Colours,
$scope.model.Colour);
}
$scope.ColourChange = function () {
$scope.model.Colour = $scope.selectedColour.value;
};
$scope.onLoad();
});
Filter.js
angular.module('umbraco').filter('getByValue',
function () {
return function (Colours, value) {
var i = 0, len = Colours.length;
for (; i < len; i++) {
if (Colours[i].value == value) {
return Colours[i];
}
}
return null;
}
});
ColourClassPicker.html
<div ng-controller="ColourClassPicker.controller">
<select id="ColourSelect"
data-ng-model="selectedColour"
data-ng-options="c.id as c.colour for c in Colours"
ng-change="ColourChange()"></select>
</div>
I reckon i am using something simple but i have been messing around with it and seem to be little lost.
was hoping someone could point me in the correct direction. I am also new to angular so my knowledge is limited.