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.

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.