0

I'm learning Angular 2. In order for that I'm creating a component which should receive as parameter in its attributes an array of other components.

Here is my code so far:

<card
  [actions]='[<icon name="tick"></icon>]'
>
  <span>Example</span>
</card>

In this case, to my component Card I'm trying to send an array, (in this case of just one component) of another component.

This is not working. How should I fix that?

EDIT

What I'm trying to do, is to render inside that card component the actions components in one part of the component, and ng-content in other part of the component

Community
  • 1
  • 1
Pablo
  • 9,424
  • 17
  • 55
  • 78

1 Answers1

0

That's not gonna work. <icon name="tick"></icon> can be treated as HTML and added like <div [innerHTML]="someHtml"> but this isn't going to become a component.

Angular 2 dynamic tabs with user-click chosen components shows a way how this could be done in Angular2.

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567
  • Maybe I'm asking wrong. What I need to do, is to add an html, which inside the object, should be rendered in other part that the `ng-content` – Pablo May 25 '16 at 20:38
  • 1
    If you want to add HTML you have to add ot to a template of a component and then add the component. If you add HTML from a string `` directly it will not become an `IconComponent` and bindings like `[name]` are not processed by Angular.. – Günter Zöchbauer May 26 '16 at 04:22