首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular-bootstrap中的Typeahead插件不适用于我

angular-bootstrap中的Typeahead插件不适用于我
EN

Stack Overflow用户
提问于 2014-01-08 08:15:59
回答 2查看 2.1K关注 0票数 0

我不能让angular-bootstrap中的typeahead特性在一个简单的yeoman生成的环境中工作。我期望的是能够开始在输入字段中键入,并有一个下拉菜单显示与输入字段中键入的字符相匹配的内容。要匹配的项目集是'alpha','beta','gamma','delta‘,但如果我输入a,什么都不会显示,但它们应该都会显示出来,因为a对所有人都是通用的。感谢任何人的帮助。

下面是我设置测试应用程序的步骤:

代码语言:javascript
复制
$ yo angular
Include twitter bootstrap Y
Twitter bootstrap with Compass N
Included all modules and took defaults for the rest

$ bower install angular-bootstrap --save

$ bower install angular-ui-bootstrap --save

编辑app/views/main.html (代码片段):

代码语言:javascript
复制
            <div class="jumbotron">
                <h1>'Allo, 'Allo!</h1>
                <p class="lead">Always a pleasure scaffolding your apps.</p>
                <p><a class="btn btn-lg btn-success" href="#">Splendid!</a></p>
            </div>

            <!-- Added this to verify that $scope.shows is available (and it is) -->
            <h2>Shows</h2>
            <ul ng-repeat="show in shows">
            <li>{{show}}</li>
            </ul>

            <!-- This is what is not working -->
            <h2>typeahead</h2>
            <input type="text" ng-model="selected" typeahead="show for show in shows | filter:$viewValue | limitTo:8" class="form-control">

            <div class="row marketing">
                <h4>HTML5 Boilerplate</h4>

编辑应用程序/脚本/控制器/main.js:

代码语言:javascript
复制
            'use strict';

            angular.module('wtfoApp', ['ui-bootstrap'])
              .controller('MainCtrl', function ($scope) {
                $scope.awesomeThings = [
                  'HTML5 Boilerplate',
                  'AngularJS',
                  'Karma'
                ];
                $scope.shows = ['alpha', 'beta', 'gamma', 'delta'];
              });

非常感谢。

编辑:忘记依赖ui-bootstrap。这可能是我的问题的解决方案,但我在添加它时遇到了麻烦。Firebug抱怨它找不到ui-bootstrap。我还尝试了bower_components/angular-bootstrap/ui-bootstrap和/angular_bootstrap。但是已经很晚了,所以我得早上再来取一次。

编辑2:遵循vucalur的建议添加angular-ui-bootstrap。这将在bower_components/angular-ui-bootstrap下添加一个模板文件夹

做了这样的更改: ui-bootstrap -> 'ui-bootstrap‘。未显示任何页面,Firebug错误为:

$injector:modulerr无法实例化模块ui-bootstrap,因为:$injector:nomod模块'ui-bootstrap‘不可用!您要么拼写错误模块名称,要么忘记加载它。如果注册一个模块,请确保将依赖项指定为第二个参数。

编辑3:通过重新运行yo和bower进行重构(使用bower尝试添加--save开关)。同样的结果。这就像是缺少了类路径之类的东西,不让我在bower_components中引用依赖项。

EN

回答 2

Stack Overflow用户

发布于 2014-01-18 01:58:42

尝试使用ui.bootstrap而不是ui-bootstrap:您需要的是句点,而不是破折号。

票数 4
EN

Stack Overflow用户

发布于 2014-01-08 15:37:04

看一看this提交。(以防我们重新建立基础,而链接不再有效:https://github.com/vucalur/django-wibses,"feat(token-dropdown) ...“提交。)

  • 项目使用的是yeoman。
  • 在后台是CoffeeScript & Python,但我希望你能从中学到一些东西。
  • 项目是从服务器获得的- JSONP$http promise api来发挥作用,但如果你有项目在客户端,你可能不需要它。
  • 还注意到,你不需要使用angular-ui-bootstrap.
  • Dependency的bootstrap3分支是"angular-ui-bootstrap": "~0.9.0",而不是angular-boostrap。至少这对我来说是有效的。
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20984679

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档