Skip to content

@Template.directives can take Bindings (not just types) #709

@mhevery

Description

@mhevery

The @Template.directives should take full Binding support.

@Template({
  url: '...',
  directives: [
    Directive1, 
    bind(Directive2).toClass(Directive2Impl),
  ]
}) 

UPDATE 1

The reason for this issue is something like this.

<tabs>
  <pane></pane>
</tabs>
@Component({selector: 'tabs'})
class Tabs {}

@Component({selector: 'pane'})
class Pane {
  constructor(tabs:Tabs) {}
}

Here Pane can inject Tabs. But what if you would like to write a different tab which participates is this. Imagine this.

<view-stack>
  <pane></pane>
</view-stack>
@Component({selector: 'view-stack'})
class ViewStack extends Tabs {}

The above would not work even thought ViewStack implements Tabs.

So to fix this we would do this:

  directives: [
    Pane, 
    bind(Tabs).toClass(ViewStack),
  ]

And it would work as expected.

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions