Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/21.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 typeahead-还显示文件版本,并选中复选框_Angularjs_Twitter Bootstrap - Fatal编程技术网

AngularJS typeahead-还显示文件版本,并选中复选框

AngularJS typeahead-还显示文件版本,并选中复选框,angularjs,twitter-bootstrap,Angularjs,Twitter Bootstrap,我在应用程序中使用以下代码: <input type="text" class="form-control" placeholder="Search document" data-ng-model="file" typeahead="document as document.fileName for docume

我在应用程序中使用以下代码:

           <input type="text" 
                   class="form-control" 
                   placeholder="Search document" 
                   data-ng-model="file"
                   typeahead="document as document.fileName for document in vm.findDocumentsByTerm($viewValue)"
                   typeahead-min-length="2"
                   typeahead-wait-ms="100"
                   typeahead-editable="false"
                   typeahead-on-select="vm.attachFile(file)" />

我不仅会显示文件名(document.fileName),还会显示文档的版本(document.versions),它是一个数组和一个复选框,用于选择文档的版本。 有可能这样做吗

[编辑] 多亏了叶斯坎,这正是我所需要的。现在看起来是这样的:

这是我的html代码:

<input type="text" 
   class="form-control" 
   data-ng-model="file"
   typeahead="document as document.fileName for document in vm.findDocumentsByTerm($viewValue)"
   typeahead-template-url = "sampleTemplate.htm"  />
 <script type="text/ng-template" id="sampleTemplate.htm">
  <div>
    <table class="table">
        <tr data-ng-click="$event.stopPropagation()">
            <td>{{match.model.fileName}}</b></td>           
            <td>
                <div data-ng-repeat="documentFileVersion in match.model.documentFileVersions">
                    <input type="checkbox" data-ng-model="vm.documentFileVersion" data-ng-click="vm.addDocumentFile(vm.documentFileVersion)" /> {{documentFileVersion.version}}
                </div>
            </td>
        </tr>
    </table>
  </div>
 </script>

{{match.model.fileName}
{{documentFileVersion.version}

当前未调用函数vm.addDocumentFile(vm.documentFileVersion)。有人知道我必须做什么才能调用此函数吗?

我确信我完全理解您的问题,我认为您可以创建一个模板(例如sampleTemplate.html),内容如下(根据您的需要更改格式)


我不明白你的问题,请用张贴的代码说明,只有文件名显示在下拉菜单中,我的问题是是否可以显示文件名和相应的版本(版本是文件的一部分)您的意思是,对于每个文档,每个版本都应该有一个选项可供该文档使用?非常感谢,这正是我需要的设计!!您知道如何在服务中调用我的函数吗?data ng click=“vm.addDocumentFile(vm.documentFileVersion)”不会在我的AngularJS服务中调用该函数。谢谢您知道如何在服务中调用我的函数吗?请澄清您的意思?
<div>
        <span ng-bind-html="match.model.fileName + match.model.version | uibTypeaheadHighlight:query"></span>
    </div>
class="form-control" 
               placeholder="Search document" 
               data-ng-model="file"
               typeahead="document as document.fileName for document in vm.findDocumentsByTerm($viewValue)"
               typeahead-min-length="2"
               typeahead-wait-ms="100"
               typeahead-editable="false"
               typeahead-on-select="vm.attachFile(file)"
               typeahead-template-url =  "sampleTemplate.htm" />