Angularjs Angular UI引导Typeahead模板显示为空,但仅第一次显示
这很奇怪…我第一次在输入框中输入时,typeahead模板会弹出,但会显示为空。但如果退格并再次执行此操作,则模板将填充。这就像在Angularjs Angular UI引导Typeahead模板显示为空,但仅第一次显示,angularjs,angular-ui-bootstrap,Angularjs,Angular Ui Bootstrap,这很奇怪…我第一次在输入框中输入时,typeahead模板会弹出,但会显示为空。但如果退格并再次执行此操作,则模板将填充。这就像在typeahead模板url中存在某种竞争条件一样。之后,该问题将消失,直到下一页刷新。有什么想法吗 angular.module("main.loadbalancer").controller("BindNodeCtrl", function($scope, $modalInstance, VipService, NodeService, Account, Stat
typeahead模板url
中存在某种竞争条件一样。之后,该问题将消失,直到下一页刷新。有什么想法吗
angular.module("main.loadbalancer").controller("BindNodeCtrl", function($scope, $modalInstance, VipService, NodeService, Account, StatusTrackerService) {
(function(promise) {
return $scope.getNodeLabel = function(val) {
return promise.then(function(nodes) {
var dropDownItems;
dropDownItems = [];
_.forEach(nodes, function(node) {
if (_.str.include(node.id.toLowerCase(), val.toLowerCase())) {
return dropDownItems.push({
label: node.label,
address: node.address,
port: node.port_number,
value: node.id,
});
}
});
return _.sortBy(dropDownItems, 'label');
});
};
})(NodeService.getNodes());
{{match.model.label}—{{match.model.address}—{{match.model.port}
我今天刚刚遇到这个问题,发现问题在于模板文件中内容周围的脚本标记。只有在内联包含模板时才需要脚本标记。如果模板位于外部文件(如您的文件)中,则应删除脚本标记。我不确定它们为什么会导致退格错误,但是删除脚本标记为我解决了这个问题。我希望这对您也有帮助,也许其他人可以了解一下幕后发生了什么,从而让这一切首先发生。我今天刚刚遇到这个问题,发现问题在于模板文件中内容周围的脚本标记。只有在内联包含模板时才需要脚本标记。如果模板位于外部文件(如您的文件)中,则应删除脚本标记。我不确定它们为什么会导致退格错误,但是删除脚本标记为我解决了这个问题。我希望这对您也有帮助,也许其他人可以了解幕后发生的事情,让这一切首先发生。非常感谢!也救了我。非常感谢你!也救了我。
<input type="text" id="label" name="label" ng-model="$parent.node.id" typeahead-min-length="1"
placeholder="Node Name / Label"
typeahead-editable="false"
typeahead="dropDownItem as dropDownItem.label for dropDownItem in getNodeLabel($viewValue)"
typeahead-template-url="typeahead/bind-node.html" style="width:100%;"
typeahead-loading="loadingNodeLabels" class="form-control" required>
<script type="text/ng-template" id="typeahead/bind-node.html">
<a><i>{{match.model.label}} — {{match.model.address}} — {{match.model.port}}</i></a>
</script>