iFarklı Modüllerde kullanmak için boruyu global olarak nasıl bildiririm? Şimdi
(i) Module1
(ii) Module2
i Module1 ve Module2'de içe bir hata söyleyerek diyor, özel bir boru CurrConvertPipe
import {Pipe, PipeTransform} from '@angular/core';
import {LocalStorageService} from './local-storage';
@Pipe({name: 'currConvert', pure: false})
export class CurrConvertPipe implements PipeTransform {
constructor(private currencyStorage: LocalStorageService) {}
transform(value: number): number {
let inputRate = this.currencyStorage.getCurrencyRate('EUR');
let outputputRate = this.currencyStorage.getCurrencyRate(localStorage.getItem('currency'));
return value/inputRate * outputputRate;
}
}
adında oluşturulan sahip daha yüksek bir modülde bildirilmelidir.
Yani ben app.module.ts
import './rxjs-extensions';
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';
import { CurrConvertPipe } from './services/currency/currency-pipe';
@NgModule({
imports: [
BrowserModule,
FormsModule,
HttpModule,
AppRoutingModule,
Module1,
Module2
],
declarations: [
AppComponent,
CurrConvertPipe
],
providers: [
],
bootstrap: [AppComponent]
})
export class AppModule { }
içine ilan ettiler Ama Module1 kullanıldığında bir, boru 'currConvert'
@Sajeetharan app.module _imports_ 'Module1' ve' Module2', bu nedenle bu modüllerdeki * * * boruları içe aktarılmaz. 'Module1' içinde 'SharedModule 'öğesini içe aktarırsanız, boru' SharedModule'de içe aktarılır ve' Module1 'öğesine aktarılır. – Ledzz