2015-02-06 162 views
0

这里捣鼓:http://jsfiddle.net/TU6tp/47/如何更改选择框后的选择框文本?

这儿如果我选择在下拉菜单中的任何选项,我会在选择框的文本获得相同的,但我需要“改变产品组合”我得到应该有选择anyor改变投资组合。

如果你看见小提琴U将容易理解什么,我想说

CODE

<select 
    ng-model="selectedItem" 
    ng-options="o.label for o in selectables"> 
    </select> 

    <p>Portfolio manager: {{selectedItem.value}}</p> 
    <p>Group: {{selectedItem.manager}}</p> 
    <p>Group name: {{selectedItem.groupname}}</p> 

回答

0

可以使用ng-change两个范围变量selectedItemxselectedItem

Fiddle

<select 
    ng-model="selectedItemx" 
    ng-options="o.label for o in selectables" ng-change="changeLable()"> 
</select> 

$scope.changeLable = function() { 
    $scope.selectedItem = $scope.selectedItemx; 
    $scope.selectables[0]['label'] = "CHANGE PORTFOLIO"; 
    $scope.selectedItemx = $scope.selectables[0];   
} 

// this is the model that's used for the data binding in the select directive 
// the default selected item 
$scope.selectedItemx = $scope.selectables[0];