var app=angular.module('myapp',['ui.bootstrap','ui.select']);
app.controller('mycontroller',function($scope){
$scope.onStateSelected = function (selectedItem) {
$scope.selectedState=selectedItem.name;
}
$scope.oncarearchange=function(item){
$scope.selectedLocation=item.name;
}
var state=[{"name":"entry"},{"name":"intermediate"},{"name":"senier"},{"name":"teamlead"}];
var carearlevel=[{"name":"entry"},{"name":"intermediate"},{"name":"senier"}{"name":"teamlead"}];
$scope.states=state;
$scope.carear=carearlevel;
});
<ui-select ng-model="field.jobtype" theme="select2" ng-disabled="disabled" class="form-control input-md c-square" on-select="onStateSelected($item)">
<ui-select-match placeholder="Select a jobtype...">
{{$select.selected.name}}
</ui-select-match>
<ui-select-choices repeat="state.name as state in states | filter: $select.search">
{{state.name}}
</ui-select-choices>
</ui-select>
这里将数组状态的ui-select显示值分配给$ scope.states,但是当尝试显示字段时,控制器中的jobtype显示错误,工作类型未定义
答案 0 :(得分:0)
当我使用$ scope.field时它工作。 ------在我的angularjs控制器中