Burada html girişi var. Giriş olaylarını dinler ve modeli güncelleriz (burada basit bir dizedir). Şimdi model için Int türünü kullanmak ve Int'nin giriş değerinden ayrılmasını istiyorum. Başka bir kod çözücü yaptım ve ilk modelin değerini 0 olarak değiştirdim. Bu değişikliklerden sonra, rakam yazarken model değişmiyor. Niye ya? Nasıl uygulanır?Elm'de int için html-girdisi nasıl çözülür?
import Html exposing (input, div, text)
import Html.Events
import StartApp.Simple
import Json.Decode
model = ""
view address model =
let
decoder =
Html.Events.targetValue
-- this decoder doesn't work
decoderInt =
Json.Decode.at ["target", "value"] Json.Decode.int
in
div [] [
input [ Html.Events.on "input" decoder (Signal.message address) ] [],
text (toString model)
]
update action model =
action
main =
StartApp.Simple.start { model = model, view = view, update = update }