# Templates, v-model, and Events This note explains how Vue templates talk to your script code. ## Templates are HTML with Vue features Example: ```vue ``` The same variable is: - shown inside `{{ username }}` - edited by `` - changed by the `reset()` function ## `{{ ... }}`: show a value ```vue

{{ username }}

{{ isLoading ? 'Loading...' : 'Done' }}

{{ 2 + 3 }}

``` This is interpolation. It prints a value into the rendered HTML. ## `v-model`: two-way binding `v-model` connects a form field and a reactive variable. ```vue ``` ```ts const email = ref(''); ``` Two-way binding means: - if the user types, `email` changes - if code changes `email`, the input display changes ## Example with a select ```vue ``` ```ts const countries = ['Germany', 'France', 'Spain']; const selectedCountry = ref(null); ``` When the user picks France, `selectedCountry.value` becomes `'France'`. ## Your real example From FlexibilityTable: ```vue ``` This means: - the dropdown shows options from `periodStartOptions` - each option is an object - `title` is shown to the user - `value` is stored in `selectedPeriodStartFrom` If one item is: ```ts { title: '2026-03-23', value: '2026-03-23T23:00:00.000Z' } ``` then the user sees: ```text 2026-03-23 ``` but the stored value becomes: ```ts selectedPeriodStartFrom.value = '2026-03-23T23:00:00.000Z'; ``` ## Events with `@click` `@click` means: call a function when the element is clicked. ```vue ``` ```ts function increment() { count.value += 1; } ``` Other common events: ```vue