内の他のコンポーネントの結果に注入コンポーネントは、私のコードの一部です:上記のコードとでここシングルトン
@Component({
selector: '...',
templateUrl: " "
})
export class QuoteComponent {
address: boolean[] = [false, false];
constructor() { }
...
}
import { QuoteComponent } from "...";
@Component({
selector: '...',
templateUrl: "...",
})
export class Addresses1Component {
constructor(private quote: QuoteComponent) { }
}
import { QuoteComponent } from "...";
@Component({
selector: '...',
templateUrl: "...",
})
export class Addresses2Component {
constructor(private quote: QuoteComponent) { }
}
プロバイダどこでもを定義せず、QuoteComponent
はシングルトンとAddresses1Component, Addresses2Component
それへのアクセスを持っています。 のサービスのように振る舞い、私はproviders
の配列のどこかに定義していないので、シングルトンではないことが期待されます。それについての良い説明?
)コンストラクタにコンポーネントを挿入しています。なぜこれがコンパイルされるのか不思議です。しかし、それ以来、QuoteComponentは角型コンポーネントやサービスとしてではなく、グローバル変数として使用されています。しかし、私はここで推測しています。なぜあなたはサービスを作成しないのか、何らかの説明をしてください。 – Ore
このコンポーネント(QuoteComponent)は、他の2つのアドレスコンポーネントにまたがるフォームを作成します。だからこそ、私はそのプロパティと値を取得するために、それを注入したいのです。 –