gpt4 book ai didi

angular - Dart英雄 Angular 旅行2:大写

转载 作者:行者123 更新时间:2023-12-03 02:57:11 26 4
gpt4 key购买 nike

我一直在使用Dart作为语言从Angular2网站上的“英雄之旅”进行跟踪,尝试使用大写管道时出现错误:

Build error:
Transform TemplateCompiler on angular2_tour_of_heroes|lib/heroes_component.ng_meta.json threw error: Template parse errors:
The pipe 'uppercase' could not be found ("

这是我的 heroes_component.html文件:
<h2>My Heroes</h2>
<ul class="heroes">
<li *ngFor="let hero of heroes"
[class.selected]="hero == selectedHero"
(click)="onSelect(hero)">
<span class="badge">{{hero.id}}</span> {{hero.name}}
</li>
</ul>
<div *ngIf="selectedHero != null">
<h2> {{selectedHero.name | uppercase}} is my hero </h2>
<button (click)="gotoDetail()">View Details</button>
</div>

没什么大不了的,但是我想知道为什么会这样。我在Linux上使用发布版本1.18.1和Dart VM版本:1.18.1。

为了完整起见,这是我的pubspec文件:
name: angular2_tour_of_heroes
description: Tour of heroes
version: 0.0.1
environment:
sdk: '>=1.13.0 <2.0.0'
dependencies:
angular2: 2.0.0-beta.18
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: web/main.dart
- dart_to_js_script_rewriter

最佳答案

更新

您的pubspec.yaml将Angular2限制为beta.18,但已经有beta.19可用。

如果将依赖关系更改为

dependencies:
angular2: ^2.0.0-beta.18

并运行 pub upgrade,您将获得最新版本。
我不知道与管道相关的更改,但是值得一试(根据下面的评论,此问题已得到修复)。

原始

您需要在 pubspec.yaml中指定 commonPipes应该为环境
transformers:
- angular2:
platform_directives:
- 'package:angular2/common.dart#COMMON_DIRECTIVES'
platform_pipes:
- 'package:angular2/common.dart#COMMON_PIPES'
entry_points: web/main.dart

也可以看看
  • https://angular.io/docs/dart/latest/quickstart.html
  • https://github.com/angular/angular/wiki/Angular-2-Dart-Transformer#platform_pipes
  • 关于angular - Dart英雄 Angular 旅行2:大写,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39014054/

    26 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com