Skip to content
This repository was archived by the owner on May 29, 2019. It is now read-only.
This repository was archived by the owner on May 29, 2019. It is now read-only.

typeahead typeahead-input-formatter fails when promise is returned #1640

Closed
@pdanpdan

Description

@pdanpdan

Hello.

There is a problem with typeahead when the typeahead-input-formatter returns a promise, as the model.$formatters chain does not support promises.

I was able to bypass this by this ugly hack:

modelCtrl.$formatters.push(function (modelValue) {

        var candidateViewValue, emptyViewValue;
        var locals = {};

        if (inputFormatter) {

          locals['$model'] = modelValue;
--          return inputFormatter(originalScope, locals);

++          $q.when(inputFormatter(originalScope, locals))
++            .then(function(viewValue) {
++              modelCtrl.$viewValue = viewValue;
++              modelCtrl.$render();
++            });
++          return modelCtrl.$viewValue;

        } else {

But this bypasses the $formatters chain completely.
The only real solution I see is to replace the angular $formatters processing chain to use promises.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions