Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Patrick Robin 33 posts 103 karma points
    Oct 25, 2015 @ 17:13
    Patrick Robin
    0

    Property Editor help

    I'm trying to create a simple property editor that pulls values from an api and displays them as a drop down list.

    Largely everything has gone okay and the list is displayed and when selected the value is saved in the database. The problem is that when you go to edit the document type again it doesn't set the selected item in the list.

    My controller looks like this:

    angular.module("umbraco")
    .controller("Emailer.PickerController",
        function ($scope, $http) {
            $http.get("/umbraco/backoffice/api/EmailerApi/GetAll/").success(function (data) {
                $scope.forms = data;
            }).error(function () {
    
            });
        });
    

    And my view looks like this:

    <div ng-controller="Emailer.PickerController">
    <select class="umb-editor umb-dropdown" required>
        <option ng-repeat="form in forms" value="{{form.Reference}}" ng-selected="{{form.Reference == model.value}}">{{form.Name}}</option>
    </select>
    <textarea ng-model="model.value"></textarea>
    

    And my package manifest looks like this:

    {
    propertyEditors: [
        {
            alias: "Emailer.Picker",
            name: "Emailer Picker",
            editor: {
                view: "~/App_Plugins/Emailer/picker.html",
                valueType: "STRING"
            }
        }
    ],
    
    javascript: [
        "~/App_Plugins/Emailer/picker.controller.js"
    ]
    

    }

    Any body got any ideas where I'm going wrong?

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 25, 2015 @ 17:16
    Tim Geyssens
    100

    Could you see what happen if you set the ng-model directive in the select so

    <select ng-model="model.value">
    ...
    
  • Patrick Robin 33 posts 103 karma points
    Oct 25, 2015 @ 17:45
    Patrick Robin
    0

    Thought I'd tried that already but obviously not as now I've added it in it's all working as expected. Cheers for the help and the rapid response!

  • Tim Geyssens 6562 posts 15373 karma points MVP 2x c-trib
    Oct 25, 2015 @ 17:51
    Tim Geyssens
    0

    Great, glad it's working :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies