在回调后选择一个ui-select选项

时间:2017-02-24 00:41:57

标签: angularjs ui-select

我正在使用ui-select,我希望在回调后选择一个选项,如下所示:

controller.unit = {};
controller.units = [
    {_id: 1, name: "day"},
    {_id: 2, name: "week"},
    {_id: 3, name: "month"},
    {_id: 4, name: "date"}
];
controller.update_type = function(type_id){
    if (controller.add_newspaper_type_form_hide == true) {
        controller.add_newspaper_type_form_hide = false;
    }
    $scope.update_type_newspaper = true;
    var url = $scope.get_url("type_newspaper");
    $http({
        method: 'POST',
        url: url,
        params: {
            'get_all': 'False',
            'type': type_id,
            'method': 'GET'
        }
    }).then(function (response) {
        controller.newspaper_type_update_data = response['data']['value']['type'];
        controller.unit.selected = response['data']['value']['type']['unit'];
    });
}

我的ui-select html是:

<ui-select ng-model="vm.unit.selected.name" on-select="ChangingUnit($item)">
                                <ui-select-match placeholder="please select one of units">
                                    <span ng-bind="$select.selected.name"></span>
                                </ui-select-match>
                                <ui-select-choices
                                        repeat="unit in vm.units | propsFilter: {name: $select.search} track by unit['_id']">
                                    <span ng-bind="unit.name"></span>
                                </ui-select-choices>
                            </ui-select>

但这不起作用。有什么问题?

0 个答案:

没有答案