我想试着在我的Angular 应用程序中使用material 拖放,但一个只包含此代码的组件从字面上复制了https://material.angular.io/cdk/drag-drop/overview

<div cdkDropList cdkDropListOrientation="horizontal" class="example-list" (cdkDropListDropped)="drop($event)">
    @for (tok of sentTokens; track tok) {
    <div class="example-box" cdkDrag>{{tok}}</div>
    }
</div>

causes me these errors even though I don't see any unescaped brackets in this code
Invalid ICU message. Missing '}'
Unexpected character "EOF" (Do you have an unescaped "{" in your template? Use "{{ '{' }}") to escape it.)

可能的原因是什么?

推荐答案

您没有运行Angular 17,因此您没有可用的The new Conditional statements syntax@for@If语法,请将您的代码更改为

<div cdkDropList cdkDropListOrientation="horizontal" class="example-list" (cdkDropListDropped)="drop($event)">
    <ng-container *ngFor="tok of sentTokens; trackBy: tok">
        <div class="example-box" cdkDrag>{{tok}}</div>
    </ng-container>
</div>

Angular相关问答推荐

如何取消针叶林输入的自动填充?

PrimeNG侧栏清除primeNG消息.为什么?

如何用ANGLE指令覆盖Html元素的数据绑定属性

Angular 16:CSRF配置:我仍然可以使用HttpXsrfInterceptor和HttpXsrfCookieExtractor类吗?Inteli-J说他们不存在

更改动态表单控制Angular 的值

属性';apiUrl';在我的Angular 应用程序上不存在类型';{}';错误

Angular 信号 - 使用 mutate() 与使用 forEach() react 性

应该显示在表格中的嵌套循环

iss 声明无效 Keycloak

如何在 Angular 2 模板中使用枚举

为什么 Angular2 (click) 事件没有在

使用 NPM 安装 Font Awesome 5

res.json() 不是函数

Angular 2 - 什么是Root Scope?

在 RxJS Observable 中 flatten数组的最佳方法

Angular 5 中 value 和 ngValue 的区别

Angular 应用程序中的语法错误:Unexpected token <

在 Angular 2 中使用 store (ngrx) 有什么好处

@HostBinding 与 Angular 中的变量类

如何在项目中导入 Angular material?