angular - 如何使用 *ngFor 外部的索引访问数据
问题描述
我想访问 *ngFor 之外的数据
<mat-carousel timings="250ms ease-in" [autoplay]="false" interval="5000" color="accent" maxWidth="93%"
proportion="80" slides="3" slideHeight="100%" [loop]="false" [hideArrows]="false" [hideIndicators]="true"
[useKeyboard]="false" [useMouseWheel]="false" orientation="ltr" maintainAspectRatio="false">
<mat-carousel-slide #matCarouselSlide *ngFor="let event of myvideo; let i = index"
overlayColor="#00000040" [hideOverlay]="true">
<video *ngIf="event?.Video" controls style="width: 100%;">
<source src="{{event?.Video}}" type="video/mp4">
Browser not supported
</video>
</mat-carousel-slide>
***I want to get in this part {{event?.title}}***
</mat-carousel>
请问你能和我分享任何想法吗?这是可能的?
解决方案
@Site,我认为您正在寻找ng-container - 它不会创建额外的标签-
<ng-container *ngFor="let event of myvideo; let i = index">
<mat-carousel-slide #matCarouselSlide >...
</mat-carousel-slide>
{{event?.title}}
</mat-carousel>
但我真的认为“标题”应该在 mat-carousel-slide 里面
推荐阅读
- ios - 在 Swift 中使用 .reverse() 时项目顺序错误
- python - 如何将字符串附加到 Pandas DataFrame?
- vue.js - 如何使 .vue 文件在 VS2019 Net Code 3.1 中工作
- bigcommerce - 如何使 BigCommerce 小部件与 PageBuilder 兼容
- azerothcore - 艾泽拉斯世界服务器无法启动win10
- django - 在 Django 项目中将网站图标放在哪里?
- reactjs - React.Lazy(() => import 在 Firefox 上不起作用,使用 HTTPS
- xml - 将xml数据转换成csv格式
- angularjs - 用于验证字符串的 ngPattern
- qt - 为什么我的 QML 代码从 Qt.labs 加载 FileDialog,尽管我导入了 QtQuick.Dialogs?