简体   繁体   English

Dart英雄角旅行2:大写

[英]Angular2 Tour of Heroes in Dart: uppercase

I have been following the Tour of Heroes from the Angular2 site using Dart as the language and I have an error when I try to use the uppercase pipe: 我一直在使用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 ("

Here is my heroes_component.html file: 这是我的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>

It's not a big deal, but I'd like to know why this is happening. 没什么大不了的,但是我想知道为什么会这样。 I'm using pub version 1.18.1 and Dart VM version: 1.18.1 on Linux. 我在Linux上使用发布版本1.18.1和Dart VM版本:1.18.1。

For completeness, here is my pubspec file: 为了完整起见,这是我的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

Update 更新

Your pubspec.yaml limits Angular2 to beta.18 but there is already beta.19 available. 您的pubspec.yaml将Angular2限制为beta.18,但已经有beta.19可用。

If you change the dependency to 如果将依赖关系更改为

dependencies:
       angular2: ^2.0.0-beta.18

and run pub upgrade you'll get the newest version. 并运行pub upgrade您将获得最新版本。 I'm not aware of changes related to pipes but it's worth a try (and this fixed it according to the comment below). 我不知道与管道有关的更改,但是值得一试(根据下面的评论,此问题已得到修复)。

Original 原版的

You need to specify in pubspec.yaml that commonPipes should be ambient 您需要在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

See also 也可以看看

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM