使用选择框中的值更新文本区域

Update textarea with a value from a selectbox

本文关键字:更新 文本 区域 选择      更新时间:2023-09-26

在AngularJS中,当用户选择时,如何将值从select设置为textarea字段。

<div class="controls" ng-controller = "TemplateCtrl">
    <select ng-model = "template" ng-options="template.fname for template in templates">    
        <option value="">-- choose template --</option>                
    </select>
    Currently selected: {{ {selected_template:template} }}   
</div>

有人能帮我吗?

HTML

           <div ng-controller = "fessCntrl"> 
                     <select ng-model = "template" ng-options="template.fname as template.fname for template in templates">    
                        <option value="">-- choose template --</option>                
                     </select>
                  Currently selected: {{ template }}
            </div>

JS

$scope.templates =[
                   {'fname':'hello there1'},
                   {'fname':'hello there2'},
                   {'fname':'hello there3'}
                  ]; 

演示Fiddle