feat(change_detection): added changeDetection to Component
This commit is contained in:
@ -480,6 +480,17 @@ export class Directive extends Injectable {
|
||||
* @publicModule angular2/annotations
|
||||
*/
|
||||
export class Component extends Directive {
|
||||
/**
|
||||
* Defines the used change detection strategy.
|
||||
*
|
||||
* When a component is instantiated, Angular creates a change detector, which is responsible for propagating
|
||||
* the component's bindings.
|
||||
*
|
||||
* The changeDetection property defines if the change detection will be checked every time or only when the component
|
||||
* tell it too.
|
||||
*/
|
||||
changeDetection:string;
|
||||
|
||||
/**
|
||||
* Defines the set of injectable objects that are visible to a Component and its children.
|
||||
*
|
||||
@ -534,13 +545,15 @@ export class Component extends Directive {
|
||||
bind,
|
||||
events,
|
||||
services,
|
||||
lifecycle
|
||||
lifecycle,
|
||||
changeDetection
|
||||
}:{
|
||||
selector:String,
|
||||
selector:string,
|
||||
bind:Object,
|
||||
events:Object,
|
||||
services:List,
|
||||
lifecycle:List
|
||||
lifecycle:List,
|
||||
changeDetection:string
|
||||
}={})
|
||||
{
|
||||
super({
|
||||
@ -550,6 +563,7 @@ export class Component extends Directive {
|
||||
lifecycle: lifecycle
|
||||
});
|
||||
|
||||
this.changeDetection = changeDetection;
|
||||
this.services = services;
|
||||
}
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ export function createDefaultSteps(
|
||||
new DirectiveParser(directives),
|
||||
new TextInterpolationParser(parser),
|
||||
new ElementBindingMarker(),
|
||||
new ProtoViewBuilder(changeDetection, shadowDomStrategy),
|
||||
new ProtoViewBuilder(compiledComponent, changeDetection, shadowDomStrategy),
|
||||
new ProtoElementInjectorBuilder(),
|
||||
new ElementBinderBuilder(parser),
|
||||
new ElementBinderBuilder(parser)
|
||||
];
|
||||
|
||||
return steps;
|
||||
|
@ -8,6 +8,8 @@ import {CompileStep} from './compile_step';
|
||||
import {CompileElement} from './compile_element';
|
||||
import {CompileControl} from './compile_control';
|
||||
import {ShadowDomStrategy} from '../shadow_dom_strategy';
|
||||
import {DirectiveMetadata} from '../directive_metadata';
|
||||
import {Component} from 'angular2/src/core/annotations/annotations';
|
||||
|
||||
/**
|
||||
* Creates ProtoViews and forwards variable bindings from parent to children.
|
||||
@ -24,8 +26,12 @@ import {ShadowDomStrategy} from '../shadow_dom_strategy';
|
||||
export class ProtoViewBuilder extends CompileStep {
|
||||
changeDetection:ChangeDetection;
|
||||
_shadowDomStrategy:ShadowDomStrategy;
|
||||
constructor(changeDetection:ChangeDetection, shadowDomStrategy:ShadowDomStrategy) {
|
||||
_compiledComponent:DirectiveMetadata;
|
||||
|
||||
constructor(compiledComponent:DirectiveMetadata,
|
||||
changeDetection:ChangeDetection, shadowDomStrategy:ShadowDomStrategy) {
|
||||
super();
|
||||
this._compiledComponent = compiledComponent;
|
||||
this._shadowDomStrategy = shadowDomStrategy;
|
||||
this.changeDetection = changeDetection;
|
||||
}
|
||||
@ -33,7 +39,10 @@ export class ProtoViewBuilder extends CompileStep {
|
||||
process(parent:CompileElement, current:CompileElement, control:CompileControl) {
|
||||
var inheritedProtoView = null;
|
||||
if (current.isViewRoot) {
|
||||
var protoChangeDetector = this.changeDetection.createProtoChangeDetector('dummy');
|
||||
var componentAnnotation:Component = this._compiledComponent.annotation;
|
||||
var protoChangeDetector = this.changeDetection.createProtoChangeDetector('dummy',
|
||||
componentAnnotation.changeDetection);
|
||||
|
||||
inheritedProtoView = new ProtoView(current.element, protoChangeDetector,
|
||||
this._shadowDomStrategy, this._getParentProtoView(parent));
|
||||
|
||||
|
Reference in New Issue
Block a user