AngularJS模板中的if else语句

给你一囗甜甜゛ 提交于 2020-08-17 00:00:47

问题:

I want to do a condition in an AngularJS template. 我想在AngularJS模板中做一个条件。 I fetch a video list from the Youtube API. 我从Youtube API获取视频列表。 Some of the videos are in 16:9 ratio and some are in 4:3 ratio. 某些视频的比例为16:9,有些视频的比例为4:3。

I want to make a condition like this: 我想这样一个条件:

if video.yt$aspectRatio equals widescreen then 
    element's attr height="270px"
else
    element's attr height="360px"

I'm iterating the videos using ng-repeat . 我正在使用ng-repeat迭代视频。 Have no idea what should I do for this condition: 不知道该如何应对这种情况:

  • Add a function in the scope? 在范围内添加功能?
  • Do it in template? 是否在模板中?

解决方案:

参考一: https://stackoom.com/question/14KyU/AngularJS模板中的if-else语句
参考二: https://oldbug.net/q/14KyU/if-else-statement-in-AngularJS-templates
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!