ng-init 値に基づいて、部分的な html ファイルのスタイルを非表示、表示、または変更しようとしています。
私のパーシャルは次のとおりです。
<article class="preview {{size}}" ng-if="desktop">
<a class="cover absolute" style="background-image:url(/images/samples/sample-image.jpg);">
<div class="post-info absolute full-width padding">
<h2 ng-if="artist" class="text-center">band name</h2>
<h3 class="post-title section-spacer" ng-if="!artist">title of news artcle <span>2hrs</span></h3>
<p ng-if="caption==true; !artist" class="post-caption">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud</p>
</div>
<div class="post-preview-gradient"></div>
</a>
</article>
メインの html ページには、次の設定があります。
<div class="row push-to-11 small-up-1 medium-up-2 large-up-3 section-spacer-large">
<div class="column" ng-init="size='threequart-padding-bottom'; artist = true; " ng-include="'/partials/elements/posts/post-preview-regular.html'"></div>
<div class="column" ng-init="size='threequart-padding-bottom'; artist = false; " ng-include="'/partials/elements/posts/post-preview-regular.html'"></div>
</div>
どちらも現在、あたかも のように属性を取得していますartist = false。
いつ、いつ ng-init を使用しないかについて複数の記事を読みましたが、これが各 div で更新されない理由についてまだ混乱しています。このパーシャルを複数のページで使用しているため、パーシャルとして含めることは理にかなっています。