Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

handle function calls in directives #3

Closed
ECorreia45 opened this issue Jan 1, 2022 · 1 comment
Closed

handle function calls in directives #3

ECorreia45 opened this issue Jan 1, 2022 · 1 comment
Labels
enhancement New feature or request feature request something requested by external user won't do something does not match current milestone or there is another reasonable workaround

Comments

@ECorreia45
Copy link
Contributor

The following can be too much for template:

<li repeat="app.todos.filter(todo => app.searchTerm.length >= 3 ? todo.title.toLowerCase().search(app.searchTerm) >= 0 : true)"
></li>

This should be able to be formatted to

<li repeat="getSearchMatchedList(app.todos)"></li>

Right now the directive don't handle function calls as value, like the on* attributes do

@ECorreia45 ECorreia45 added enhancement New feature or request feature request something requested by external user labels Jan 1, 2022
@ECorreia45
Copy link
Contributor Author

This can be done by using a getter like so:

class ExampleComponent extends WebComponent {
    get searchMatchedList() {
       return this.app.todos
            .filter(todo => this.app.searchTerm.length >= 3 
                    ? todo.title.toLowerCase().search(this.app.searchTerm) >= 0 
                    : true)
    }
}
<li repeat="this.searchMatchedList"></li>

@ECorreia45 ECorreia45 added the won't do something does not match current milestone or there is another reasonable workaround label Jan 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feature request something requested by external user won't do something does not match current milestone or there is another reasonable workaround
Projects
None yet
Development

No branches or pull requests

1 participant