2015-09-07 1 views
0

Как конвертировать normal select list код в angular-ui-selectdirective код.нормальный список выбора для углового-ui-select не работает

Мой код HTML:

<select class="input-small tight-form-input" ng-model="panel.valueName" ng-options="f.value as f.text for f in bigValueOptions" ng-change="render()"></select> 

Мой код контроллера:

$scope.bigValueOptions= [{ 
    text: 'min', 
    value: 'min' 
    }, { 
    text: 'max', 
    value: 'max' 
    }, { 
    text: 'avg', 
    value: 'avg' 
    }, { 
    text: 'current', 
    value: 'current' 
    }, { 
    text: 'total', 
    value: 'total' 
    }]; 

То, что я пробовал:

<ui-select id="viewSelector" 
         class="viewSelector input-small tight-form-input" 
         ng-model="panel.valueName" 
         theme="selectize" 
         ng-change="render()"> 
         <ui-select-match placeholder="Select">{{$select.selected.text}}</ui-select-match> 
         <ui-select-choices repeat="f in bigValueOptions"> 
          <div ng-bind-html="f.text"></div> 
         </ui-select-choices> 
        </ui-select> 

panel.valueName не имеющий правильное значение. Как исправить это или как преобразовать нормальный выбор в ui-select directuve code.

Просим руководствоваться.

ответ

0

Это работает для меня: Plunker

ли вы определили $scope.panel = {};?

JS:

app.controller('DemoCtrl', function($scope, $http) { 
    $scope.bigValueOptions= [{ 
    text: 'min', 
    value: 'min' 
    }, { 
    text: 'max', 
    value: 'max' 
    }, { 
    text: 'avg', 
    value: 'avg' 
    }, { 
    text: 'current', 
    value: 'current' 
    }, { 
    text: 'total', 
    value: 'total' 
    }]; 
    $scope.panel = {}; 
}); 

HTML:

<body ng-controller="DemoCtrl"> 
    Selected object: {{panel.valueName}} 
    <ui-select id="viewSelector" 
     class="viewSelector input-small tight-form-input" 
     ng-model="panel.valueName" 
     theme="selectize" 
     ng-change="render()"> 
     <ui-select-match placeholder="Select">{{$select.selected.text}}</ui-select-match> 
     <ui-select-choices repeat="f in bigValueOptions"> 
     <div ng-bind-html="f.text"></div> 
     </ui-select-choices> 
    </ui-select> 
</body> 
Смежные вопросы