Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
angular2 rc6定制全球管道;平台管道_Angular_Typescript_Import - Fatal编程技术网

angular2 rc6定制全球管道;平台管道

angular2 rc6定制全球管道;平台管道,angular,typescript,import,Angular,Typescript,Import,我在2.0.0-rc版本中使用angular。6在旧版本中,可以创建一个全局管道并将其注册,如图所示,以及在线的许多其他位置 我正在尝试在我的应用程序中执行类似的操作,但遇到了一个问题, 我无法从angular/core导入平台_管道,而且我还了解到,在和其他联机位置上,平台_管道已被弃用 我在这件事上发现了这一点,但它对我没有帮助,因为我正在使用@NgModule,而且我似乎找不到任何方式将管道放入其中的方法 有什么想法吗?默认管道和自定义管道的工作演示: 默认管道 import { Pip

我在2.0.0-rc版本中使用angular。6在旧版本中,可以创建一个全局管道并将其注册,如图所示,以及在线的许多其他位置

我正在尝试在我的应用程序中执行类似的操作,但遇到了一个问题, 我无法从angular/core导入平台_管道,而且我还了解到,在和其他联机位置上,平台_管道已被弃用

我在这件事上发现了这一点,但它对我没有帮助,因为我正在使用@NgModule,而且我似乎找不到任何方式将管道放入其中的方法


有什么想法吗?

默认管道和自定义管道的工作演示:


默认管道

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'awesome' })

export class AwesomePipe implements PipeTransform {
  transform(phrase: string) {
    return phrase ? 'Awesome ' + phrase : '';
  }
}
你不需要为此做任何事情

由于平台_管道已被弃用,在RC6中,默认管道在默认情况下可用


自定义管道

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'awesome' })

export class AwesomePipe implements PipeTransform {
  transform(phrase: string) {
    return phrase ? 'Awesome ' + phrase : '';
  }
}
我想在AppComponent中使用它

 @NgModule({
   imports:      [ BroswerModule, FormsModule ],
   declarations: [ AppComponent, AwesomePipe ],  //<----added here
   exports:      [ AppComponent],
   providers:    [ ]
  })

默认管道和自定义管道的工作演示:


默认管道

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'awesome' })

export class AwesomePipe implements PipeTransform {
  transform(phrase: string) {
    return phrase ? 'Awesome ' + phrase : '';
  }
}
你不需要为此做任何事情

由于平台_管道已被弃用,在RC6中,默认管道在默认情况下可用


自定义管道

import { Pipe, PipeTransform } from '@angular/core';

@Pipe({ name: 'awesome' })

export class AwesomePipe implements PipeTransform {
  transform(phrase: string) {
    return phrase ? 'Awesome ' + phrase : '';
  }
}
我想在AppComponent中使用它

 @NgModule({
   imports:      [ BroswerModule, FormsModule ],
   declarations: [ AppComponent, AwesomePipe ],  //<----added here
   exports:      [ AppComponent],
   providers:    [ ]
  })

我说的是自定义全局类型,而不是默认类型。这是我的问题,如何注册它?好的,非常感谢,这正是我需要的!我还用这两种类型的管道更新了我的plunker链接。我说的是自定义全局类型,而不是默认类型。这是我的问题,如何注册它?好的,非常感谢这正是我需要的!我还用这两种类型的管道更新了我的plunker链接。