0

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.

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:

.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.

What am I missing?

1 Answer 1

1

I think maybe it should be viewValue instead of viewvalue. Notice the cap. 'V'

Sign up to request clarification or add additional context in comments.

1 Comment

Why doesn't information like this show up in the console? Is there a way to get bindings to log exceptions, such as using an undefined variable like this?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.