こちらのサイト(https://npmdaily.com/pkg/ng2-bs-dropdown)を参考にangular2でbootstrapのdropdownを実装したいのですが、うまくいきません。
angular-cli(1.0.0-beta.32.3)でng new appコマンドでプロジェクトを作り、
下記のコマンドを実行
npm install --save intl@1.2.5 bootstrap@3.3.7 ng2-bootstrap@1.1.14
npm install ng2-bs-dropdown --save
を実行。
app.component.html内に
<div class="dropdown"> <button class="btn btn-primary dropdown-toggle" type="button" id="dropdownMenu1"> Dropdown </button> <div class="dropdown-menu" aria-labelledby="dropdownMenu1"> <a class="dropdown-item" href="#">Action</a> <a class="dropdown-item" href="#">Another action</a> <a class="dropdown-item" href="#">Something else here</a> </div> </div>
上記コードを入力し
app.component.tsは
import { Component } from '@angular/core'; import {DROPDOWN_DIRECTIVES} from "ng2-bs-dropdown"; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.css'], directives: [DROPDOWN_DIRECTIVES] }) export class AppComponent { title = 'app works!'; }
このように変更しました。
しかし、
directives: [DROPDOWN_DIRECTIVES]
に
「Argument of type '{selector:string;tempplateUrl:string;styleUrls:string[];directives:any[][];}'is not assignable to parameter of type'Component'.Object literal may only specify known properties,and'directibes'does not exist in type 'Component'.」
というエラーが発生します。読んだ限りでは、
・directivesには2次元配列を入力
・Componentにはdirectibesは使えない
と警告を受けているように思うのですが、具体的にどのように解決したらいいのかがわかりません。
ご存知の方いらっしゃいましたら、よろしくお願いします。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。