单击内部脚本类型的模板不起作用
ng click inside script type ng template is not working
我想制作自定义打字头AngularBootstrapUI,这是我的自定义模板:
<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");
})
};
您可以使用angularui-bootstrap提供的以下功能:
$scope.onSelect = function ($item, $model, $label) {
//$scope.$item = $item;
//$scope.$model = $model;
//$scope.$label = $label;
};
每当用户从预先输入的选项中选择任何选项时,此函数将 运行。所以你可以打开一个模式来显示多个结果。
您可以在此处的预输入设置标题下找到此功能:
http://angular-ui.github.io/bootstrap/#/typeahead
示例:
$scope.onSelect = function ($item, $model, $label) {
var id = $item.id;
// This function opens a modal
// You could also create an alert
$scope.getMarketPlayerID(id);
// This statement clears the input to blank
$scope.selected = "";
};
我想制作自定义打字头AngularBootstrapUI,这是我的自定义模板:
<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");
})
};
您可以使用angularui-bootstrap提供的以下功能:
$scope.onSelect = function ($item, $model, $label) {
//$scope.$item = $item;
//$scope.$model = $model;
//$scope.$label = $label;
};
每当用户从预先输入的选项中选择任何选项时,此函数将 运行。所以你可以打开一个模式来显示多个结果。
您可以在此处的预输入设置标题下找到此功能: http://angular-ui.github.io/bootstrap/#/typeahead
示例:
$scope.onSelect = function ($item, $model, $label) {
var id = $item.id;
// This function opens a modal
// You could also create an alert
$scope.getMarketPlayerID(id);
// This statement clears the input to blank
$scope.selected = "";
};