我需要帮助才能在组合框中获取选定的值并显示它。附件是一段代码,显示了我尝试过的内容。
<label class="col-sm-4 control-label">Issue Type:</label>
<div>
<select ng-model="selectedIssue" ng-options="task as task.calltypename for task in tasktype"><option value="" >Please Select</option></select>
</div>
答案 0 :(得分:1)
这是HTML代码,希望这有帮助
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<select ng-model="selectedIssue" ng-options="item as item.calltypename for item in names">
</select>
<label>Issue type:{{selectedIssue.calltypename}}</label>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.names = [{calltypename:'Emil'},{calltypename:'Emily'}, {calltypename:'Emial'}];
});
</script>
答案 1 :(得分:0)
试试这个样本:
<强> HTML 强>
<div ng-app="App" >
<div ng-controller="ctrl">
<select ng-model="blisterPackTemplateSelected" ng-change="changedValue(blisterPackTemplateSelected)"
data-ng-options="blisterPackTemplate as blisterPackTemplate.name for blisterPackTemplate in blisterPackTemplates">
<option value="">Select Option</option>
</select>
{{itemList}}
</div>
</div>
<强> JS 强>
var app=angular.module('App', []);
function ctrl($scope){
$scope.itemList=[];
$scope.blisterPackTemplates=[{id:1,name:"a"},{id:2,name:"b"},{id:3,name:"c"}]
$scope.changedValue=function(item){
$scope.itemList.push(item.name);
}
}
以下是输出
希望它对你有所帮助。