如何在angularjs对象属性中获取值



如何在控制器中获取field.jobtype的值?

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从分配给$scope.states的数组状态中选择显示值,但当试图在控制器中显示字段jobtype时,它显示错误jobtype没有定义。

当我在angularjs控制器中使用$scope.field时,它就工作了

相关内容

  • 没有找到相关文章

最新更新