jokade / angulate2

Scala.js bindings for Angular
MIT License
87 stars 15 forks source link

Provide basic scalatags for built-in directives and bindings #51

Closed jokade closed 7 years ago

jokade commented 7 years ago

Example in-line scalatags template:

import angulate2.ext.tags.simple._
import scalatags.Text.all._

@Component(
  template = tpl(
   h2("HEROES"),
    div(ngIf:="hero")(
      h3("{{ hero.name }}"),
      div(
        label("Id: "),"{{ hero.id }}",
        input(ngModel:="hero.name", placeholder:="name")
      ),
      p(
        button(ngClick:="gotoHeroes()")("Back")
      )
    )
  )
)
class HeroDetailComponent
n3phtys commented 7 years ago

This is an interesting idea, but only works if we have some kind of macro that generates custom tags for every component in the classpath, including strongly typed Output/Input fields (meaning we get IDE autocomplete for free, which is huuuuuge!). With strongly typed Output/Input fields this wrapper would become uniquely qualified in the Angular world. I don't think there is any TypeScript based HTML wrapper yet capable of dealing with Angular components.

Ambitious project, nonetheless.

jokade commented 7 years ago

Well, it is (currently) not my plan to automatically create scalatags for components. Right now I'm only adding Angular2-specific tags and attributes.