2016-09-26 9 views
2

最近、BootstrapプロジェクトでAngular 2で作業を開始しました。私はUIにブートストラップトグルチェックボックスを追加したい。私はダウンロードし、thisサイトの指示に従った。チェックボックスはトグルされて表示されませんが、通常のチェックボックスとして表示されます。 Index.htmlとは、次のとおりです。BootstrapトグルチェックボックスがAngular 2コンポーネントで動作しない

<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <meta http-equiv="X-UA-Compatible" content="IE=Edge"> 
 

 
    <!--[if lt IE 9]> 
 
      <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> 
 
     <![endif]--> 
 
    <script> 
 
    document.write('<base href="' + document.location + '" />'); 
 
    </script> 
 

 
    <script src="node_modules/jquery/dist/jquery.js"></script> 
 

 
    <!-- Bootstrap JS dependencies--> 
 
    <link rel="stylesheet" href="content/css/bootstrap.min.css" /> 
 
    <link rel="stylesheet" href="content/css/font-awesome.min.css"> 
 
    <link rel="stylesheet" href="content/css/bootstrap-toggle.min.css" /> 
 
    <link rel="stylesheet" href="content/css/app-styles.css" /> 
 
    <script src="content/js/bootstrap.min.js"></script> 
 

 

 
    <!-- 1. Load libraries --> 
 
    <!-- Polyfill(s) for older browsers --> 
 
    <script src="node_modules/core-js/client/shim.min.js"></script> 
 
    <script src="node_modules/zone.js/dist/zone.js"></script> 
 
    <script src="node_modules/reflect-metadata/Reflect.js"></script> 
 
    <script src="node_modules/systemjs/dist/system.src.js"></script> 
 

 
    <!-- 2. Configure SystemJS --> 
 
    <script src="systemjs.config.js"></script> 
 

 

 
    <script> 
 
    System.import('app').catch(
 
     function(err) { 
 
     console.error(err); 
 
     }); 
 

 
    $(function() { 
 
     $('#showOpen').bootstrapToggle(); 
 
    }) 
 
    </script> 
 

 
</head> 
 

 
<body> 
 

 
    <my-web-app>Loading ...</my-web-app> 
 

 
    <script src="content/js/bootstrap-toggle.js"></script> 
 

 
</body> 
 

 

 
</html>

コードスニペット

ここで、私のウェブアプリは、フォームを作成し、角度2のコンポーネントを呼び出します。フォームこれは、トグルチェックボックスとしてチェックボックスを表示されない

<div class="form-group"> 
 
    <label for="showOpen" class="col-md-4 control-label">Show Open :</label> 
 
    <div class="col-md-1 checkbox"> 
 
    <input [(ngModel)]="model.showOpen" name="showOpen" type="checkbox" id="showOpen" data-toggle="toggle" checked class="control-form"> 
 
    </div> 
 
</div>

ようにチェックボックスを有します。チェックボックスは、通常のHTMLチェックボックスとして表示されます。

ご覧のとおり、初期化コードもindex.htmlに追加しました。

しかし、Index.htmlファイルの最初の要素(my-web-appより前)としてトグルチェックボックスを追加すると、正しく表示されます。私が何が欠けているか分からない。助けてください。

答えて

関連する問題