Skip to content

Instantly share code, notes, and snippets.

@jmn
Created October 2, 2017 07:29
Show Gist options
  • Save jmn/f2595a8f307d72c3a0510ece936ef733 to your computer and use it in GitHub Desktop.
Save jmn/f2595a8f307d72c3a0510ece936ef733 to your computer and use it in GitHub Desktop.
Increment Button click example
module Main exposing (..)
import Html exposing (..)
import Html.Events exposing (..)
type alias Model = Int
model : Model
model = 0
main : Program Never Model Msg
main =
Html.beginnerProgram { model = model, view = view, update = update }
view : Model -> Html Msg
view model =
div []
[ div []
[ button [ onClick Increment ] [ text (toString(model)) ]
]
]
type Msg
= Increment
update : Msg -> Model -> (Model)
update msg model =
case msg of
Increment ->
( model + 1 )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment