javascriptangularjsangular-uiangular-ui-select

Using ui-tagging with single choice


i'm a newbie on angularjs and angular-ui and i have a problem with module ui-select. I need to select single element from a list and if there isn't a value, the user can add manually, but the tagging system of ui-select doen't work for a single value and i don't know why.

This is the ui-select code:

<ui-select tagging="tagStation" tagging-label="(Add station)" ng-model="new.station">
  <ui-select-match placeholder="Choose or Add">{{$select.selected.label}}</ui-select-match>
   <ui-select-choices repeat="station.value as station in stationList | filter: { label: $select.label }">
    <div ng-bind-html="station.label | highlight: $select.search"></div>
   </ui-select-choices>
 </ui-select>

And this is the function for tagging attribute:

$scope.tagStation = function (newTag) {
            var item = {
                label: newTag,
                value: 0
            };

            return item;
        };

Can someone help me? Thx


Solution

  • Check out the thread and the particular answer I'm linking to here. There's a workaround for now where you add the attribute tagging-label="false". Hopefully that fixes your problem! I'm looking at a similar issue, but unfortunately for me, this workaround doesn't seem to address my particular problem as I can't get any custom value to stick.