Skip to content

KonstantineGoudz/ember-dropdown

Repository files navigation

lister

This is an example of how to setup a dropdown selection in ember

Prerequisites

You will need to assign a controller for your route for this to work properly

quick example

  • create a route

    ember generate route drop
  • create a contoller

    ember generate controller drop-controller
  • associate the controller with the route in app/routes/drop.js

    import Route from '@ember/routing/route';
    
    export default Route.extend({
        controllerName: 'dropController', // the generated controller
        model() { // the model for the  route which will be passed to the conroller
            return {
                options: [
                    "test",
                    "cool",
                    "ffart"
                ]
            }
        }
    });
  • Implement the action in the controller app\controllers\drop-controller.js

    import Controller from '@ember/controller';
    
    export default Controller.extend({
        actions:{
            sel(val){
                alert(val)
            }
        }
    });
  • Finally in the app\templates\drop.hbs

    <select onchange={{action "sel" value="target.value"}} >
        {{#each model.options as |opt|}}
            <option value={{opt}}>{{opt}}</option>
        {{/each}}
    </select>
    {{outlet}}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published