This is weird...the first time I will type in the input box, the typeahead
template will pop up but will show empty. But if I backspace and do it
again...then the template populates. It's like there is some kind of race
condition with typeahead-template-url. Ater that, the issue goes away until
the next page refresh. Any ideas?
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());
----------------------------------------------------------------------------------------------------
<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>
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.