5

Grunts ng-template を使用して、HTML テンプレートを $templateCache に保存しています。angular docs は、次のようにテンプレートを使用できることを示唆しています。

myApp.component('myComponent', {
   templateUrl: 'templateId.html'
});

またはこのように:

 myApp.component('myComponent', {
   template: $templateCache.get('templateId.html')
});

違いはなんですか?この関数を使用するためだけに、すべてのディレクティブ/コンポーネントに $templateCache を挿入するのはあまり好きではありません。これはパフォーマンスに関するものですか?

私はこの記事を読みました:テンプレートとtemplateUrl Angularjsの間のパフォーマンスの違いはどれくらいです か?私が正しければ、(templateUrlではなく)テンプレートを使用する方が少し高速です。違いはこれだけですか?

4

0 に答える 0