[英]Angular UI Bootstrap asynchronous typeahead: $viewValue undefined
I'm trying to set up a second typeahead in my ngViews, and even though my code is nearly identical to the first, the first works perfectly, while the second passes 'undefined' to the callback. 我正在尝试在ngViews中设置第二个typeahead,即使我的代码与第一个几乎相同,第一个也可以正常运行,而第二个将“未定义”传递给回调。
Here's the markup for non-functional typeahead: 这是非功能性提前输入的标记:
<div id="toNodePicker" ng-if="!toNode.NodeId">
<label for="to-node-name">Pick a node:</label>
<input id="to-node-name" type="text" class="form-control" placeholder="Enter node"
typeahead-wait-ms=" 50"
typeahead-min-length="3"
ng-model="selectedToNode"
typeahead="toResult.Name for toResult in nodeSearch($viewvalue)" />
</div>
And the Javascript: 和Javascript:
.controller('edgeAddCtrl', ['$scope', '$routeParams', 'graphService', 'resourceService',
function ($scope, $routeParams, graphService, resourceService) {
var fromType = null;
var toType = null;
$scope.selectedToNode = undefined;
$scope.toNode = {};
$scope.fromNodeSel = undefined;
$scope.fromNode = {};
if ($routeParams.nodeId) {
graphService.getNode($routeParams.nodeId)
.then(function(data) {
$scope.fromNode = data.data;
if ($scope.fromNode) {
fromType = $scope.fromNode.NodeTypeId;
}
if ($scope.toNode) {
toType = $scope.toNode.NodeTypeId;
}
graphService.getEdgeTypes(fromType, toType)
.then(function (data) {
$scope.edgeTypes = data.data;
$scope.selectedEdgeType = {};
});
});
}
$scope.nodeSearch = function(s) {
return graphService.getNodesForNewEdge(s, 'to', $scope.fromNode, $scope.toNode, $scope.selectedEdgeType.EdgeTypeId)
.then(function(data) {
return data.data;
});
}
$scope.edgeTypes = [];
}]);
The only differences left between the functional and the non-functional typeahead that I can spot are the variable names and the callback, yet s is consistently undefined every time I hit my breakpoint in nodeSearch . 我可以发现的功能性和非功能性类型之间的唯一区别是变量名和回调,但是每次我在nodeSearch中遇到断点时, s始终是未定义的 。
What am I missing? 我想念什么?
I think maybe it should be viewValue instead of viewvalue. 我认为也许应该是viewValue而不是viewvalue。 Notice the cap. 注意瓶盖。 'V' 'V'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.