2016-11-29 11 views
0

無料のhtml5テンプレートをダウンロードし、それを私のangular2プログラムで使用する予定です。問題は、bodyをindex.htmlの外側またはapp.component.htmlの内側に置くと、テンプレートが機能しないことです。何も表示しません。すべてのsrcを正しく置くことができると確信しています。見てみましょう。index.html以外の場合にサードパーティのライブラリが動作しない

index.htmlをapp.component.html

<div id="fh5co-services" class="fh5co-bg-section"> 
    <div class="container"> 
     <div class="row"> 
      <div class="col-md-4 col-sm-4 text-center"> 
       <div class="feature-center animate-box" data-animate-effect="fadeIn"> 
        <span class="icon"> 
         <i class="icon-credit-card"></i> 
        </span> 
        <h3>Credit Card</h3> 
        <p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove</p> 
        <p><a href="#" class="btn btn-primary btn-outline">Learn More</a></p> 
       </div> 
      </div> 
      <div class="col-md-4 col-sm-4 text-center"> 
       <div class="feature-center animate-box" data-animate-effect="fadeIn"> 
        <span class="icon"> 
         <i class="icon-wallet"></i> 
        </span> 
        <h3>Save Money</h3> 
        <p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove</p> 
        <p><a href="#" class="btn btn-primary btn-outline">Learn More</a></p> 
       </div> 
      </div> 
      <div class="col-md-4 col-sm-4 text-center"> 
       <div class="feature-center animate-box" data-animate-effect="fadeIn"> 
        <span class="icon"> 
         <i class="icon-paper-plane"></i> 
        </span> 
        <h3>Free Delivery</h3> 
        <p>Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in Bookmarksgrove</p> 
        <p><a href="#" class="btn btn-primary btn-outline">Learn More</a></p> 
       </div> 
      </div> 
     </div> 
    </div> 
</div> 

ナッシングで

<!DOCTYPE html> 
<html> 
    <head> 
    <title>Angular QuickStart</title> 
    <meta charset="UTF-8"> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <link rel="stylesheet" href="styles.css"> 

    <!-- Facebook and Twitter integration --> 
    <meta property="og:title" content=""/> 
    <meta property="og:image" content=""/> 
    <meta property="og:url" content=""/> 
    <meta property="og:site_name" content=""/> 
    <meta property="og:description" content=""/> 
    <meta name="twitter:title" content="" /> 
    <meta name="twitter:image" content="" /> 
    <meta name="twitter:url" content="" /> 
     <meta name="twitter:card" content="" /> 

    <!-- Animate.css --> 
    <link rel="stylesheet" href="assets/css/animate.css"> 
    <!-- Icomoon Icon Fonts--> 
    <link rel="stylesheet" href="assets/css/icomoon.css"> 
    <!-- Bootstrap --> 
    <link rel="stylesheet" href="assets/css/bootstrap.css"> 

    <!-- Flexslider --> 
    <link rel="stylesheet" href="assets/css/flexslider.css"> 

    <!-- Owl Carousel --> 
    <link rel="stylesheet" href="assets/css/owl.carousel.min.css"> 
    <link rel="stylesheet" href="assets/css/owl.theme.default.min.css"> 

    <!-- Theme style --> 
    <link rel="stylesheet" href="assets/css/style.css"> 

    <!-- Modernizr JS --> 
    <script src="assets/js/modernizr-2.6.2.min.js"></script> 
    <!-- FOR IE9 below --> 
    <!--[if lt IE 9]> 
    <script src="js/respond.min.js"></script> 
    <![endif]--> 

     <!-- 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> 

    <script src="systemjs.config.js"></script> 
    <script> 
     System.import('app').catch(function(err){ console.error(err); }); 
    </script> 
    </head> 

    <body> 

    <my-app></my-app> 

    <!-- jQuery --> 
    <script src="assets/js/jquery.min.js"></script> 
    <!-- jQuery Easing --> 
    <script src="assets/js/jquery.easing.1.3.js"></script> 
    <!-- Bootstrap --> 
    <script src="assets/js/bootstrap.min.js"></script> 
    <!-- Waypoints --> 
    <script src="assets/js/jquery.waypoints.min.js"></script> 
    <!-- Carousel --> 
    <script src="assets/js/owl.carousel.min.js"></script> 
    <!-- countTo --> 
    <script src="assets/js/jquery.countTo.js"></script> 
    <!-- Flexslider --> 
    <script src="assets/js/jquery.flexslider-min.js"></script> 
    <!-- Main --> 
    <script src="assets/js/main.js"></script> 

    </body> 
</html> 

いくつかのコードは、ここで示しています。ここでのことは、すべてをindex.htmlに入れると完全に動作しますが、bodyタグからコードを取得してapp.component.htmlに配置すると、タグに行くことになります。isn表示されません。私のセレクターは正しいですし、私はそれを確信しています。誰でも説明したり、解決策を教えたりしますか?それは非常に高く評価されるだろう。

+1

とAngularJSを使用しているとき、あなたはangular.element(要素)を利用することができますか?何が表示されると思いますか?多くのコードがありますが、私は関連する部分が何であるかは分かりません。 "outside index.html"はどこですか? –

+0

外部index.htmlは、app.component.htmlまたは他のhtmlファイルを意味します。私はindex.htmlと必要なすべてのjsファイルにCSSの要件をすべて入れましたが、本体は他のhtmlファイルに存在する必要があります。今、index.htmlファイル内にすべてのコードを置くと、正しく読み込まれ、期待通りにbodyタグの内容をすべて削除してapp.component.htmlの中に入れると、動作しません。 –

答えて

1

Jqueryプラグインは、角型アプリケーションでは期待通りに機能しません。代わりに、ディレクティブを作成し、通常はこのディレクティブのリンク機能の中に配置します。

ドキュメンテーションにはいくつかの点があります。

ビューでスクリプトを参照しているときに、angularjsライブラリ、コントローラ、サービス、およびフィルタが参照された後で最後に参照するようにしてください。

むしろより$(要素)を使用して問題は何jQueryの

Refer this blog

0
<script>タグは、コンポーネントのテンプレート(そこにいくつかのメタデータのためにそれらを可能にプル要求があるが、それはまだ上陸していない)

CSSファイルは@Component({ styleUrls: [...]})にしていないテンプレートで<style>タグに追加する必要がありますから、剪定され

関連する問題