BuilderIO / BuilderIO/mitosis

Move Angular event handlers to methods

Open
#503 3 comments 0 reactions 1 assignee Claimed by @PatrickJS View on GitHub
angular bug
Dominant language
TypeScript
Stars
14.4k
Forks
671
PR merge metrics
No merged PRs in 30d

Description

### Currently

As with other output, the Angular output passes in-line event handling code through. For example, this input:

```
(state.list = [...state.list, state.newItemName])}
>
```

Produces this output:

```

Add list item

```

This will not work in the general case (or in the specific case above), because Angular has its own notion of the syntax that works for an in-line event handler. Angular does not accept arbitrary TypeScript or JavaScript like a JSX/TSX-based framework.

### Expected

To make Angular output work for nontrivial event handlers, it will probably be necessary to output the event handling code into a method in the component, and call that method from the generated event handler, roughly like so:

```

Add list item

handleClick() {
this.list = [...this.list, this.newItemName]
}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.