2

I just want to implement an example of typeahead before apply on my live project. Every example working fine on their site but it's not working for me.

I have done:

<input id='itemInput' type="text" ng-model="item" placeholder="Item Name" typeahead="item as item.Index for item in states | filter:$viewValue" class="form-control">

Template:

<ul class="dropdown-menu" ng-show="isOpen() && !moveInProgress" ng-style="{top: position().top+'px', left: position().left+'px'}" role="listbox" aria-hidden="{{!isOpen()}}">
    <li class="uib-typeahead-match" ng-repeat="match in matches track by $index" ng-class="{active: isActive($index) }" ng-mouseenter="selectActive($index)" ng-click="selectMatch($index, $event)" role="option" id="{{::match.id}}">
        <div uib-typeahead-match index="$index" match="match" query="query" template-url="templateUrl"></div>
    </li>
</ul>

Attached:

var app = angular.module('MascoDyeing', ["ngRoute", "ngMaterial", "md.time.picker", 'long2know',
    'ngSanitize',
    'ui.bootstrap',
    'ui.bootstrap.typeahead',
    'ui.router',
    'ngRoute',
    'ui']);

Script

<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>

Any suggestion would be appreciated.

4

1 回答 1

0

这是模板中的 ng-style-part:

ng-style="{top: position().top+'px', left: position().left+'px'}"

在某些情况下,位置是一个对象而不是一个函数。您可以尝试以这种方式解决它:

ng-style="{top: (position.top || position().top)+'px', left: (position.left || position().left)+'px'}"
于 2021-04-13T08:13:20.153 回答