-
Notifications
You must be signed in to change notification settings - Fork 27.1k
Closed
Milestone
Description
Goal
Have the ability to declare templates in one location, but have them rendered in another.
Implementation
- The
Viewshould be created at declaration location, with local context, injection etc. (This also implies that we should have aChangeDetectorinserted at declaration location) - The Destination should receive the
Viewand set local vars on it. - The Destination should insert the
Viewinto theViewContainer(Render Location)
Ionic Example
<div>
<template toolbar-part #i="index">
<button (click)="onClick()">{{i}}: {{action}}</button>
</template>
</div>some other place:
<toolbar>
<!-- place where the toolbar-part will be inserted -->
</toolbar>@Component({
selector: 'toolbar'
})
class Toolbar {
viewContainer:ViewContainer;
constructor(viewContainer:ViewContainer) {
this.viewContainer = viewContainer;
}
addView(view:View) {
view.setLocal('index', this.viewContainer.length);
this.viewContainer.add(view);
}
}
@Viewport({
selector: 'toolbar-part'
})
class {
constructor(viewFactory:ViewFactor, toolbar:Toolbar) {
var view:ViewRef = viewFactory.create();
toolbar.addView(view);
}
}Issues
- The template expressions need to be executed in the context of where the template is declared.
- The
Viewcreated by the DOM is inserted in a different location. - The insert location should be able to insert values into the inserted
Viewprovided that the template declares the variable.
Table Example
<virtual-table [data-source]>
<template row-header-cell #row="rowIndex">
{{row}} Row Header
</template>
<template col-header-cell #col="colIndex">
{{col}} Column Header
</template>
<template cell #row="rowIndex" #col="colIndex">
{{row}}:{{col}}
</template>
</virtual-table>SVG Charts Example
<bar-chart>
<template chart-title>
</template>
<svg *x-axis>
<g ...>{{text}}</g>
</svg>
</bar-chart>Issues:
- context
- injecting the other
ViewContainer - getting hold of the
PortoView
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels