【发布时间】:2013-08-18 14:37:50
【问题描述】:
我的 ruby on rails 项目中有一个正在运行的 Angular 应用程序,现在我想使用 angular.js 实现一些预先输入的搜索,但找不到如何制作 typeahead directive running 的解决方案。
问题:如何在我的项目中安装 angular typeahead 指令?
使用下面描述的当前解决方案,我得到了这个控制台:
Failed to load resource: the server responded with a status of 404 (Not Found) http://localhost:3000/template/typeahead/typeahead.html
- ng-app 正在运行,相关的 js 和 css 文件也链接到了 html。
我正在关注这个来源:bootstrap-ui-angularjs
我已经做了什么:
- 下载
angular-ui-bootstrap.js到public\assets\javascripts目录 -
像往常一样显示资产管道:
//= 需要 jquery //= 需要 jquery_ujs //= 需要 jquery.tokeninput //= 需要引导 //= 需要角度 //= 需要 angular-ui-bootstrap //= 要求树。
3.检查js是否在页面上:(只是有问题的脚本)
<link href="/assets/bootstrap.css?body=1" media="all" rel="stylesheet" type="text/css" />
<script src="/assets/bootstrap.js?body=1" type="text/javascript"></script>
<script src="/assets/angular.js?body=1" type="text/javascript"></script>
<script src="/assets/angular-ui-bootstrap.js?body=1" type="text/javascript"></script>
my ng-app:
<div ng-app='plunker'>
<div class='container-fluid' ng-controller="TypeaheadCtrl">
<pre>Model: {{result | json}}</pre>
<input type="text" ng-model="result" typeahead="suggestion for suggestion in cities($viewValue)">
</div>
</div>
<script>
angular.module('plunker', ['ui.bootstrap']);
function TypeaheadCtrl($scope, $http, limitToFilter) {
//http://www.geobytes.com/free-ajax-cities-jsonp-api.htm
$scope.cities = function(cityName) {
return $http.jsonp("http://gd.geobytes.com/AutoCompleteCity?callback=JSON_CALLBACK &filter=US&q="+cityName).then(function(response){
return limitToFilter(response.data, 15);
});
};
}
</script>
在安装现有的角度指令方面我缺少什么吗?例如来自this link
【问题讨论】:
标签: ruby-on-rails twitter-bootstrap angularjs typeahead typeahead.js