Skip to content

List attribute setters in the @Component annotation #1256

@mhevery

Description

@mhevery

Allow Directives to write properties on their current element. Currently this is handled with @ProportySetter('name') but will be move to this style for easier test ability/consistency.

Currently:

@Component({
  selector: 'my-component'
})
class MyComponent {
  constructor(
      @PropertySetter('class.my-class)' myClass,
      @PropertySetter('hidden')
  ) {
    myClass.set(true);
  }
}

Proposed:

@Component({
  selector: 'my-component',
  setters: ['hidden', 'classMyClass: class.my-class']
})
class MyComponent {
  myClass:Emitter;
  hidden:Emitter

  constructor() {
    myClass = new Emitter();
    hidden = new Emitter();
  }
}
  • setter name uses the same path as the property setter. So we intercept attr.foo, 'class.bar`, and so on. (But it does not set values on other Directives/Components)
  • Emitter can be replaced with Observables for now.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions