angular Template

angular Template

  1. ng-switch directive:
    can be used something like the following.
    <divng-switchon="video"><divng-switch-when="video.large"></div><divng-switch-default></div></div>
  2. ng-hide / ng-show directives
    Alternatively, you might also use ng-show/ng-hide but using this will actually render both a large video and a small video element and then hide the one that meets the ng-hide condition and shows the one that meets ng-show condition. So on each page you'll actually be rendering two different elements.
  3. Another option to consider is ng-class directive.
    This can be used as follows.
    <divng-class="{large-video: video.large}"></div>
    The above basically will add a large-video css class to the div element if video.large is truthy.
    UPDATE: Angular 1.1.5 introduced the ngIf directive4. ng-if directive:
    In the versions above 1.1.5 you can use the ng-if directive. This would remove the element if the expression provided returns false and re-inserts the element in the DOM if the expression returns true. Can be used as follows.
    <divng-if="video == video.large"></div><divng-if="video != video.large"></div>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容