我在過去的2天中一直在尋找這一切,所以我決定尋求幫助。 想象一下,我們有一個名爲ParentComponent的父組件,並且我們還有一個名爲SomeComponent的子組件。NativeScript - 將內容從父組件傳遞到子組件
SomeComponent模板將是:
import {Component} from "@angular/core";
@Component({
selector: "SomeComponent",
template: `
<ActionBar title="TestApp">
</ActionBar>
<StackLayout style="margin-top:20;">
<Label text="Somenthing on top"></Label>
#CONTAINER CONTENT HERE#
<Label text="Something in the bottom"></Label>
</StackLayout>
`,
})
export class SomeComponent {}
..和爲父級的模板將是:
import {Component} from "@angular/core";
import {SomeComponent} from "../some/where/...";
@Component({
selector: "parent",
template: `
<SomeComponent>
<Label text="Something here"></Label>
<Label text="Something else here"></Label>
</SomeComponent>
`,
})
export class ParentComponent {}
考慮上述的例子中,我怎麼能進去 「< SomeComponent>」 所限定的含量我的ParentComponent,要在保留的「#CONTAINER CONTENT HERE#」區域的SomeComponent中正確顯示?
從理論上講這是因爲如果我最終會是這樣的:
<ActionBar title="TestApp">
</ActionBar>
<StackLayout style="margin-top:20;">
<Label text="Somenthing on top"></Label>
<Label text="Something here"></Label>
<Label text="Something else here"></Label>
<Label text="Something in the bottom"></Label>
</StackLayout>
它看起來像是很簡單,我以前做的反應本地人,我不能去上班的NS。
在此先感謝。
是的。我已經嘗試過,但沒有奏效。這可能是我正在做的其他事情,這是阻礙。至少現在我知道這是做到這一點的方法。 TNX – alvesdm
我沒有加入我的組件,以 「聲明」: @NgModule({ 聲明: AppComponent, SomeComponent ], TNX @theOriginalJosh – alvesdm
NP,我忘了自己頻繁。 – theOriginalJosh