2

I like to know if there is way to pre-write "dynamic" Angular 2 inputs and outputs on the index.html file, and the embedded Angular 2 app can bind with those elements?

i.e. index.html

<body>
   <my-app>Loading...</my-app>
   <div>{{getData}}</div>
   <button (click)="onTestGet()">Click me to test get data</button>
</body>

where the Angular 2 app will be rendered inside the <my-app> tag.

I have made the {{getData}} and the button worked well when they are inside the Angular template. But for now, when they are inside index.html, they are just dumb elements.

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
ChrisZ
  • 482
  • 2
  • 11
  • 26

1 Answers1

1

That is not supported for security reasons.

If you want to register event handlers you need to do this imperatively with direct DOM access.

See also this similar question Angular 2 external inputs

Community
  • 1
  • 1
Günter Zöchbauer
  • 623,577
  • 216
  • 2,003
  • 1,567