设置预输入选项,采用了棱角分明的UI引导 [英] Setting options for typeahead, using Angular-ui Bootstrap

查看:183
本文介绍了设置预输入选项,采用了棱角分明的UI引导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用预输入,我想设置了几个选项,可作为标准引导的预输入选项

使用以下code,我能够通过将其在网上的预输入分钟长的设置的minLength属性,而是以项目为预输入项做同样的 才不是。是否有不同的/更好/标准做到这一点的方法吗?有没有一种办法选项数组附加到$范围?

 < D​​IV CLASS ='集装箱液'NG控制器=的TestController><输入类型=文本NG模型=选择
预输入=富在富富|过滤器:$ viewValue预输入项=5预输入分钟长度='3'>< pre> {{选择| JSON}}< / pre> < / DIV>

更新:我试图坚持只用AngularJS,而不是使用jQuery

这是我的控制器:

  myAppModule.controller('的TestController',函数($ HTTP,$范围){
  $ scope.selected =不确定;  $ http.get(数据/ sample.json')
       。然后(功能(结果){
          $ scope.foo = results.data;
      });
  });


解决方案

你为什么不使用JS的方式来初始化预输入:

  $('input.typeahead')。预输入({
    来源:array_of_value_here,
    的minLength:1,
    项目:5,
    //你的选项值...
});

编辑:

我看到的,AngularJS的方式,你可以使用 limitTo

 <输入类型=文本NG模型=选择预输入=富在富富|过滤器:$ viewValue | limitTo:5预输入分钟长='3'>

Using typeahead, I am trying to set a couple of options, which are available as standard Bootstrap typeahead options

Using the following code, I'm able to set the "minLength" property by putting it in-line as "typeahead-min-length", but doing the same with "items" as "typeahead-items" does not. Is there a different/better/standard way to do this? Is there a way to attach an array of options to $scope?

<div class='container-fluid' ng-controller="TestController">

<input type="text" ng-model="selected" 
typeahead="foo for foo in foo | filter:$viewValue" typeahead-items='5' typeahead-min-length='3'>

<pre>{{selected| json}}</pre>  </div>

Update: I'm trying to stick with just AngularJS, and not use jQuery

This is my controller:

  myAppModule.controller('TestController', function($http,$scope) {
  $scope.selected = undefined;

  $http.get('data/sample.json')
       .then(function(results){
          $scope.foo = results.data; 
      });
  });

解决方案

Why don't you use the JS way to initialize typeahead:

$('input.typeahead').typeahead({
    source: array_of_value_here,
    minLength: 1,
    items: 5,
    // your option values ...
});

EDIT:

I see, the AngularJS way, you can use limitTo:

<input type="text" ng-model="selected" typeahead="foo for foo in foo | filter:$viewValue | limitTo:5" typeahead-min-length='3'>

这篇关于设置预输入选项,采用了棱角分明的UI引导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆