- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我在我的 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
angular-ui-bootstrap.js
进入public\assets\javascripts
目录 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>
最佳答案
您可以使用 ui-bootstrap-tpls.js,而不是使用 ui-bootstrap.js。这个 js 文件随模板一起提供。
要使用 ui-bootstrap-tpls.js,您必须将 js 文件添加到您的 html 中:
<script src="/scripts/angular-ui/ui-bootstrap-tpls.js"></script>
angular.module('myModule', ['ui.bootstrap', 'ui.bootstrap.typeahead']);
Failed to load resource: the server responded with a status of 404 (Not Found) _http://localhost:3000/template/typeahead/typeahead.html
关于ruby-on-rails - 无法在 Ruby on rails 应用程序中加载模板 : template/typeahead/typeahead. html,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18269071/
我正在开发一个需要能够平均三个数字的 Facebook 应用程序。但是,它总是返回 0 作为答案。这是我的代码: $y = 100; $n = 250; $m = 300; $number = ($y
我只是无法弄清楚这一点,也找不到任何对我来说有意义的类似问题。我的问题:我从数据库中提取记录,并在我的网页上以每个面板 12 条的倍数显示它们。因此,我需要知道有多少个面板可以使用 JavaScrip
我是一名优秀的程序员,十分优秀!