Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularJS click to edit fields such as dropdown
    primarykey
    data
    text
    <p>I stumbled upon this <a href="http://icelab.com.au/articles/levelling-up-with-angularjs-building-a-reusable-click-to-edit-directive/" rel="nofollow">article</a> on how to build a click to edit feature for a form. The author states:</p> <blockquote> <p>What about if you wanted input type="date" or even a select? This is where you could add some extra attribute names to the directive’s scope, like fieldType, and then change some elements in the template based on that value. Or for full customisation, you could even turn off replace: true and add a compile function that wraps the necessary click to edit markup around any existing content in the page.</p> </blockquote> <p>While looking through the code I cannot seem to wrap my head around how I could manipulate the template in such a way that I could make it apply to any angular component, let alone how I can make it apply to a drop down list. Code from article below:</p> <pre><code> app.directive("clickToEdit", function() { var editorTemplate = '&lt;div class="click-to-edit"&gt;' + '&lt;div ng-hide="view.editorEnabled"&gt;' + '{{value}} ' + '&lt;a ng-click="enableEditor()"&gt;Edit&lt;/a&gt;' + '&lt;/div&gt;' + '&lt;div ng-show="view.editorEnabled"&gt;' + '&lt;input ng-model="view.editableValue"&gt;' + '&lt;a href="#" ng-click="save()"&gt;Save&lt;/a&gt;' + ' or ' + '&lt;a ng-click="disableEditor()"&gt;cancel&lt;/a&gt;.' + '&lt;/div&gt;' + '&lt;/div&gt;'; return { restrict: "A", replace: true, template: editorTemplate, scope: { value: "=clickToEdit", }, controller: function($scope) { $scope.view = { editableValue: $scope.value, editorEnabled: false }; $scope.enableEditor = function() { $scope.view.editorEnabled = true; $scope.view.editableValue = $scope.value; }; $scope.disableEditor = function() { $scope.view.editorEnabled = false; }; $scope.save = function() { $scope.value = $scope.view.editableValue; $scope.disableEditor(); }; } }; }); </code></pre> <p>My question is, how can we extend the above code to allow for drop down edits? That is being able to change to the values that get selected.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload