AcxImperativeViewUtils class
A single entrypoint library for working with highly dynamic views in Angular 2 code. This allows easier refactoring and migration of approaches as the Angular team iterates and a standard API for AngularDart components to use.
Example use (see imperative_view_test as well):
@Component(
selector: 'imperative-list',
properties: const
'items'
)
@View(
template: '',
renderer: ''
)
class ImperativeListComponent {
final AcxImperativeViewUtils _imperativeViewUtils;
final ElementRef _elementRef;
final _listElement = new Element.ul();
ImperativeListComponent(this._imperativeViewUtils, this._elementRef) {
_dynamicViewUtils.useAsImperativeView(_elementRef, _listElement);
}
set items(List<String> items) {
_listElement.children.clear();
items.forEach((item) {
final itemElement = new Element.li();
_imperativeViewUtils.insertAngularComponent(
ItemComponent,
_elementRef,
itemElement).then((ComponentRef componentRef) =>
componentRef.instance = item);
_listElement.append(itemElement);
});
}
}
@Component(
selector: 'item',
properties: const [
'value'
]
)
@View(
template: '{{value}}'
)
class ItemComponent {
String value;
}
- Annotations
-
- @Injectable()
Constructors
- AcxImperativeViewUtils(ComponentLoader _componentLoader, DomService _domService)
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
insertAngularView(
HtmlElement intoDomElement, TemplateRef templateRef, ViewContainerRef viewContainer) → Future< ImperativeViewRef> -
Returns a future that completes after inserting
templateRef
into template location, preservingexistingLocation
's scope if supplied. -
insertComponent<
T extends Object> (ComponentFactory< T> componentFactory, ViewContainerRef viewContainer, HtmlElement intoDomElement, {Injector? injector}) → Future<ComponentRef< T> > -
Returns a future that completes with a new instance created by
componentFactory
, once it is insertedintoDomElement
. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited