私はこの2日間でこれを探していましたので、私は助けを求めることにしました。 ParentComponentという名前の親コンポーネントがあり、SomeComponentという子コンポーネントもあるとします。で定義されたNativeScript - 親から子コンポーネントにコンテンツを渡す
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" 内のコンテンツを取得することができます:
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 {}
..and parentComponentにテンプレートは次のようになり私の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