Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 在post回调后选择ui选择选项_Angularjs_Ui Select - Fatal编程技术网

Angularjs 在post回调后选择ui选择选项

Angularjs 在post回调后选择ui选择选项,angularjs,ui-select,Angularjs,Ui Select,我正在使用ui select,我希望在post回调后选择一个选项,如下所示: 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 (co

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

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>


但这是行不通的。怎么了?

您的
ui选择的
model值是多少?将
ui select
的模型值设置为
response['data']['value']['type']['unit']
请提供HTML。你是如何实现的。@IftekharDani我编辑了我的帖子。