私は ng2-bootstrap と Angular2 を実装しています。
モバイルナビゲーションバーを開閉する方法がわかりません。
これはまだサポートされていないものですか?または、何か不足していますか?
更新、html:
<nav class="navbar navbar-default">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">
<img src="/logo.png" />
</a>
</div>
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li router-active>
<a [routerLink]=" ['Index'] ">Summary<span class="sr-only">(current)</span></a>
</li>
<li router-active>
<a [routerLink]=" ['Portfolio'] ">Portfolio<span class="sr-only">(current)</span></a>
</li>
<li router-active>
<a [routerLink]=" ['About'] ">About<span class="sr-only">(current)</span></a>
</li>
</ul>
<form class="navbar-form navbar-left" role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>
<ul class="nav navbar-nav navbar-right">
<li dropdown keyboardNav="true">
<a href class="dropdown-toggle" role="button" aria-expanded="false" dropdownToggle>
<span class="glyphicon glyphicon-user" aria-hidden="true"></span>
Andrew Duncan
<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li role="menuitem"><a class="dropdown-item" href="#">Account Settings</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Another action</a></li>
<li role="menuitem"><a class="dropdown-item" href="#">Something else here</a></li>
<li class="divider dropdown-divider"></li>
<li role="menuitem"><a class="dropdown-item" href="#">Logout</a></li>
</ul>
</li>
</ul>
</div>
</div>
タイプスクリプト:
/*
* Angular 2 decorators and services
*/
import { Component, ViewEncapsulation } from '@angular/core';
import { RouteConfig, Router } from '@angular/router-deprecated';
import { AppState } from './app.service';
import { Home } from './home';
import { RouterActive } from './router-active';
import { BUTTON_DIRECTIVES, DROPDOWN_DIRECTIVES } from '../../node_modules/ng2-bootstrap';
/*
* App Component
* Top Level Component
*/
@Component({
selector: 'app',
pipes: [ ],
providers: [ ],
directives: [
RouterActive,
BUTTON_DIRECTIVES,
DROPDOWN_DIRECTIVES ],
encapsulation: ViewEncapsulation.None,
styles: [
require('./app.css')
],
template: require('./app.html')
})
@RouteConfig([
{ path: '/', name: 'Index', component: Home, useAsDefault: true },
{ path: '/home', name: 'Home', component: Home },
// Async load a component using Webpack's require with es6-promise-loader and webpack `require`
{ path: '/about', name: 'About', loader: () => require('es6-promise!./about')('About') },
{ path: '/portfolio', name: 'Portfolio', loader: () => require('es6-promise!./portfolio')('Portfolio') }
])
export class App {
angularclassLogo = 'assets/img/angularclass-avatar.png';
loading = false;
url = 'https://twitter.com/AngularClass';
constructor(
public appState: AppState) {
}
ngOnInit() {
console.log('Initial App State', this.appState.state);
}
}
/*
* Please review the https://github.com/AngularClass/angular2-examples/ repo for
* more angular app examples that you may copy/paste
* (The examples may not be updated as quickly. Please open an issue on github for us to update it)
* For help or questions please contact us at @AngularClass on twitter
* or our chat on Slack at https://AngularClass.com/slack-join
*/