gpt4 book ai didi

javascript - 将 angular-ui-select 与 Angular 种子项目结合使用

转载 作者:行者123 更新时间:2023-11-27 23:29:32 25 4
gpt4 key购买 nike

我从 https://github.com/angular/angular-seed 创建了一个基础项目我正在尝试使用 angular-ui-select 向该项目添加下拉菜单。我安装了 angular-ui-select 并将 select.js 和 select.css 添加到我的 index.html 文件中。 Angular-sanitize 也已安装。

我的 view1.html 看起来像:

 <p>This is the partial for view 1.</p>
<ui-select ng-model="vm.person.selected" style="min-width: 300px;">
<ui-select-match placeholder="Select a person in the list or search his name/age...">{{$select.selected.name}}</ui-select-match>
<ui-select-choices repeat="person in vm.people">
<div ng-bind-html="person.name | highlight: $select.search"></div>
<small>
email: {{person.email}}
age: <span ng-bind-html="''+person.age | highlight: $select.search"></span>
</small>
</ui-select-choices>
</ui-select>

我的 Controller 看起来像:

'use strict';

angular.module('myApp.view1', ['ngRoute','myApp.testDirective', 'ngSanitize', 'ui.select'])

.config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/view1', {
templateUrl: 'view1/view1.html',
controller: 'View1Ctrl',
controllerAs: 'vm'
});
}])

.controller('View1Ctrl', [function() {
var vm = this;
vm.people = [
{ name: 'Adam', email: 'adam@email.com', age: 10 },
{ name: 'Amalie', email: 'amalie@email.com', age: 12 },
{ name: 'Wladimir', email: 'wladimir@email.com', age: 30 },
{ name: 'Samantha', email: 'samantha@email.com', age: 31 },
{ name: 'Estefanía', email: 'estefanía@email.com', age: 16 },
{ name: 'Natasha', email: 'natasha@email.com', age: 54 },
{ name: 'Nicole', email: 'nicole@email.com', age: 43 },
{ name: 'Adrian', email: 'adrian@email.com', age: 21 }
];
}]);

附件是我目前看到的图片。不知道为什么它不能正常显示。 enter image description here

最佳答案

这是一个CSS问题。信不信由你。您需要添加 Bootstrap 3:

 <link rel="stylesheet" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.css">

关于javascript - 将 angular-ui-select 与 Angular 种子项目结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34687266/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com