简体   繁体   English

Angular ui-select的值

[英]Value of Angular ui-select

In my application have ui-select: 在我的应用程序中有ui-select:

<ui-select ng-model="flat.flatData.type_local" theme="bootstrap">
   <ui-select-match placeholder="Type">
      {{ $select.selected.type }}
   </ui-select-match>
   <ui-select-choices repeat="t in flat.type_local | filter: $select.search">
      {{ t.type }}
   </ui-select-choices>
</ui-select>

After chosing something i want to add value of select to database. 选择了一些东西后,我想为数据库增加select的价值。

Before i'm using input and dont have a problem with adding to database. 在我使用输入之前,添加到数据库没有问题。

<input type="text" class="form-control input-sm" name="type" ng-model="flat.flatData.type_local" placeholder="Type" required>

This is part of my controller: 这是我的控制器的一部分:

angular.module('flatCtrl', ['flatService', 'ui.grid', 'ui.grid.resizeColumns', 'ui.grid.moveColumns', 'ui.grid.autoResize', 'ngSanitize', 'ui.select'])
.controller('FlatController', function(Flat, socketio){

    vm = this;

    vm.createFlat = function(){
        vm.message = '';
        Flat.create(vm.flatData)
            .success(function(data){

                // clear up the form
                vm.flatData = '';
                vm.message = data.message;
            });
    };


    vm.type_local = [
        { type: 'One' },
        { type: 'Two' }
    ];
<input type="text" class="form-control input-sm" name="type" 
       ng-model="flat.type_local" placeholder="Type" required>

Here is the fix to this issue: 这是解决此问题的方法:

 <ui-select-choices repeat="t.type as t in flat.type_local track by $index | filter: $select.search">

and

 <div ng-bind-html="t.type | highlight: $select.search"></div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM