我有一个要求,即我的辅助导航栏是根据服务器的数据动态生成的。我需要一个类似于此的控件 - >
我需要在左侧和右侧有箭头标记,以允许用户滚动项目。我在这里找到了一些使用JQuery的示例代码。 http://www.bootply.com/l2ChB4vYmC 但我需要使用Angular 2和Bootstrap 3来实现这一点。是否有类似的东西?
答案 0 :(得分:1)
不需要像Angular 2那样类似的东西。你也可以在Angular 2中使用它。这是plunkr显示的内容。
@Component({
selector: 'my-app',
template: `
<div class="container">
<div class="scroller scroller-left"><i class="glyphicon glyphicon-chevron-left"></i></div>
<div class="scroller scroller-right"><i class="glyphicon glyphicon-chevron-right"></i></div>
<div class="wrapper">
<ul class="nav nav-tabs list" id="myTab">
<li *ngFor="let tab of tabs" class="{{tab.active ? 'active' : ''}}">
<a href="#{{tab.name}}">{{tab.name}}</a>
</li>
</ul>
</div>
</div>
`,
})
export class App {
tabs: any[] = [];
constructor() {
for(var i = 1; i < 21; i++){
this.tabs.push({
name: "Tab" + i,
active: i === 1 ? true : false
});
}
}
ngAfterViewInit(){
//Do jquery stuff to access the DOM
}
}
答案 1 :(得分:0)
OR 您可以使用这个非常容易使用的角度库 -
https://www.npmjs.com/package/angular2-drag-scroll