用angularJS进行打印
我现在使用AngularJS和Bootstrap。 我想做一个typeahead,当他被选中时(当我点击它时)显示所有选项,而不仅仅是当我在上面写东西时。就像使用JQuery的示例(我不能使用JQuery) 这是我的控制器用angularJS进行打印,angularjs,twitter-bootstrap,angular-ui-bootstrap,Angularjs,Twitter Bootstrap,Angular Ui Bootstrap,我现在使用AngularJS和Bootstrap。 我想做一个typeahead,当他被选中时(当我点击它时)显示所有选项,而不仅仅是当我在上面写东西时。就像使用JQuery的示例(我不能使用JQuery) 这是我的控制器 countrycatControllers.controller('CountryListCtrl',['$scope', function ($scope) { $scope.listCountry = [ {"name": "Swi
countrycatControllers.controller('CountryListCtrl',['$scope',
function ($scope) {
$scope.listCountry = [
{"name": "Switzerland"},
{"name": "France"},
{"name": "Spain"},
{"name": "Brazil"},
{"name": "Argentina"},
{"name": "USA"},
{"name": "Canada"},
{"name": "China"},
{"name": "Germany"},
{"name": "Italy"}
];
}
])
<pre>Model: {{country | json}}</pre>
<input data-ng-model="country" typeahead="item.name for item in listCountry | filter:$viewValue"/>
这是我的HTML输入:
Model:{{country | json}
您可以使用过滤器自行完成此操作:
{{item.name}
看。其想法是,搜索模型模仿listCountry条目的结构。ng focus和ng blur仅用于在实际单击输入元素时显示列表。Select2插件有一个100%角度指令
查看谢谢你的想法,但我正在尝试使用一个真正的typeahead,如我的示例中所示
<div ng-app>
<div ng-controller="CountryListCtrl">
<div>
<input type="text" placeholder="Enter country here" ng-model="search.name" size="80" ng-focus="modeExpanded=true" ng-blur="modeExpanded=false" />
<div ng-show="modeExpanded">
<div ng-repeat="item in listCountry | filter:search">{{item.name}}</div>
</div>
</div>
</div>
</div>