0
我想提出一個自定義typehead角度引導用戶界面,這裏是我的自定義模板:NG點擊不工作
<script type="text/ng-template" id="customTemplateall.html">
<a>
<span ng-bind-html="match.label | uibTypeaheadHighlight:query"></span>
<br>
<small>Nama Lain:{{match.model.tag}}</small>
</a>
</script>
因此,與該代碼我想提一些結果之後用戶在輸入字段中鍵入一些字符,這裏是輸入域代碼:
<div class="wrp-search">
<div class="labelsearch"><img src="images/bulb-black.png" alt=""/> Tulis Jenis Pemeriksaan</div>
<input type="text" ng-model="$parent.nama" placeholder="Contoh: Diabetes" uib-typeahead="item as item.name for item in dataall | filter:{tag:$viewValue} | limitTo:10" typeahead-min-length="2" typeahead-template-url="customTemplateall.html">
<input type="submit" class="btn-green" ng-click="cari()" />
</div>
所以,我想有多個搜索結果,例如像:1 MG Labs
所以當用戶點擊打印頭時,它會轉到多個結果,當用戶單擊「GO」時,它會直接顯示結果。
有什麼我必須做的?
更新:
這裏是myController的範圍:
$scope.onSelect = function ($item, $model, $label) {
$scope.$item = $item;
$scope.$model = $model;
$scope.$label = $label;
// alert($scope.$item.name);
$http({
method: 'POST',
url: '/api/v1/order/cart/add/byname',
data: {
name: $scope.$item.name
}
}).success(function(){
// $window.location.href = 'order/pemeriksaan';
$scope.cartget();
$scope.nama.name = ""; //this is the code
}).error(function(){
alert("pencarian gagal");
})
};
你好,感謝你的精彩回答。我只是想知道,我必須使用其範圍這樣做...在文檔中,它不告訴我每個$ item,$ model,$ label或$ event ...的功能,並且你會介意給我一個例子,只給出警告任何事情我點擊了? –
嗨,問題解決了,我只需要取消註釋你已經完成了...我只想知道如何使用戶點擊他/她想要的搜索表單爲空... –
要使輸入空白,只需將空字符串分配給輸入模型。使用寫入所有邏輯的控制器的範圍。我編輯了答案並添加了一個例子。 –