Skip to content

Commit 641e859

Browse files
committed
Merge pull request #26 from NativeScript/feature/handle-content-view
Handle content view add/remove child
2 parents bb4e270 + 8c97298 commit 641e859

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Diff for: src/nativescript-angular/view_node.ts

+11-4
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ export class ViewNode {
123123
} else {
124124
parentLayout.addChild(this.nativeView);
125125
}
126+
} else if (this.parentNativeView instanceof ContentView) {
127+
(<ContentView>this.parentNativeView).content = this.nativeView;
126128
} else if ((<any>this.parentNativeView)._addChildFromBuilder) {
127129
(<any>this.parentNativeView)._addChildFromBuilder(this.viewName, this.nativeView);
128130
} else if (this.parentNode.isComplexProperty) {
@@ -334,10 +336,15 @@ export class ViewNode {
334336
this.detachUIEvents();
335337
if (this.nativeView) {
336338
let nativeParent = this.nativeView.parent;
337-
if (nativeParent instanceof LayoutBase) {
338-
(<LayoutBase>nativeParent).removeChild(this.nativeView);
339-
} else {
340-
nativeParent._removeView(this.nativeView);
339+
if (nativeParent) {
340+
if (nativeParent instanceof LayoutBase) {
341+
(<LayoutBase>nativeParent).removeChild(this.nativeView);
342+
} else if (nativeParent instanceof ContentView) {
343+
(<ContentView>nativeParent).content = undefined;
344+
}
345+
else {
346+
nativeParent._removeView(this.nativeView);
347+
}
341348
}
342349
}
343350

0 commit comments

Comments
 (0)