如何自定义angucomplete-alt的结果

时间:2017-03-03 16:09:54

标签: javascript angularjs

我在角度项目中使用angucomplete-alt:

  <angucomplete-alt id="ex2"
    placeholder="ID Boitier"
    pause="300"
    selected-object="selectedDeviceId"
    local-data="getAllData"
    title-field="id,name"
    search-fields="name"
    minlength="3"

    input-class="form-control form-control-small"
    match-class="highlight" />

selectedDeviceId

 $scope.selectedDeviceId = function(selected) {

          if (selected) {
            var item=selected.title.replace(" ","-");
           // window.alert('You have selected ' + item);
            $scope.id=item.substring(0,item.indexOf("-"));
            //alert(id);
            //$scope.tr=item;
              $scope.PageNumber=1;
            dashboard.getTraccarData($scope.id,$scope.PageNumber,dashboard.RecordNummber);
            return item;

          } else {
            console.log('cleared');
          }


        };

它的效果很好!!但是i4m试图做的是,而不是用名字显示id,我想在这个领域用' - '分隔它们。如何实现它。

0 个答案:

没有答案