使用选择框中的值更新textarea

时间:2013-12-15 19:12:19

标签: javascript angularjs

在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>

有人可以帮助我。

1 个答案:

答案 0 :(得分:0)

<强> 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