2017-05-23 13 views
0

私はThymeleafを搭載したSpringBoot AppでホストされているAngularJSプロジェクトに取り組んでいます.ViewとRoutingを介して別のWebページからセクション要素を取得するためにAngularJSが必要です。親要素は削除しますが、その子要素はThymeleafに保持しますか?

しかし、私はThymeLeafがHTMLページ全体ではなくセクション要素を与えるようにする方法を理解することはできませんが、開発時に自然なテンプレートとしてWebページを表示することはできます。

だから、サーバーにそれが

<html> 
    <title>Don't keep this </title> 
    <body> 
     <section> 
      Keep this 
     </section> 
    </body> 
</html> 

として格納されている。しかしAngularJSがページを読み込む際に、Thymeleafは、それがこの読みます:うん、これは断片と非常に簡単です

<section> 
    Keep this 
</section> 
+0

を返します

@RequestMapping(value = "whatever.html", method = RequestMethod.GET) public String get() { return "whatever :: section"; // Where the string 'whatever' resolves to the template, and section // resolves to the text in th:fragment. } 

? –

答えて

0

を。 HTMLファイルは、次のようになります場合:

<!-- whatever.html --> 
<html> 
    <head> 
     <title>Don't keep this </title> 
    </head> 

    <body> 
     <section th:fragment="section"> 
      Keep this 
     </section> 
    </body> 
</html> 

そして、あなたのコントローラ、このような:それはあなたのThmeleafテンプレートとあなたのJSコードを追加することができ、HTML

<section> 
    Keep this 
</section> 
関連する問題