问题:
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
来源:oschina
链接:https://my.oschina.net/stackoom/blog/4338098