angular - 当响应中的标识符之一是 Angular 应用程序中的数字时,我应该如何实现模型接口
问题描述
来自 api 的示例响应:
"results":[
{
"id":16228,
"name":"ABCD",
"preview":"/d8a/d8a61a3a12e52114afdbc28f2c813f5c.jpg",
"data":{
"480":"https://mdb.net/steam/6693661/movie480.mp4",
"max":"https://mdb.net/steam/6693661/movie_max.mp4"
}
我的界面如下:
interface Movie {
data: {
max: string;
480: string;
};
}
当我尝试
<video
class="movie"
controls
*ngFor="let trailer of results"
>
<source src="{{ trailer.data.480 }}" <-------- Error here
type="video/mp4" />
Your browser does not support the video tag.
</video>
NG5002:解析器错误:[{{ trailer.data.480 }}] 中第 14 列的意外令牌“0.48”
如何解决?
另外,当问号出现时,如何修复 {{ trail.data?['480'] }}
谢谢
解决方案
你试过吗{{ trailer.data['480'] }}
推荐阅读
- amazon-web-services - 识别流视频中的人脸 AWS - 如何将实时视频连接到 Kinesis 视频流?
- sidekiq - Worker#jobs 和 Sidekiq::Queue#size 之间的区别
- javascript - 带有参数声明的 JavaScript 函数
- plot - gnuplot splot中的钳位值?
- c++ - C ++可以在'''.close()'''之后关闭'''fstream'''变量吗?
- powershell - 如何使用 powershell 将参数传递给 ADF 管道
- java - ImageView 不正确的 XY 坐标
- ruby-on-rails - 如何将haml与react js集成。我想使用Haml文件渲染react组件?
- spring-boot - Spring Boot Apache Camel 应用程序在容器中时不服务请求
- java - 如何在java上使用多个用户帐户的用户登录属性