Skip to content

Commit

Permalink
Extend component router API
Browse files Browse the repository at this point in the history
  • Loading branch information
jokade committed May 6, 2016
1 parent 8a71ce6 commit 1851cd4
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/scala/biz/enef/angulate/router/router.scala
Expand Up @@ -16,6 +16,7 @@ import de.surfice.smacrotools.JSOptionsObject

import scala.annotation.StaticAnnotation
import scala.scalajs.js
import scala.scalajs.js.Promise
import scala.scalajs.js.annotation.{JSName, ScalaJSDefined}

class RouteConfig(defs: RDef*) extends StaticAnnotation
Expand All @@ -37,4 +38,17 @@ trait RouterOnActivate extends js.Object {
@js.native
trait ComponentInstruction extends js.Object {
def params: js.Dictionary[js.Any]
}

@js.native
trait Router extends js.Object {
def navigate(changes: js.Array[js.Any]): Promise[js.Any] = js.native
def navigateByUrl(url: String): Promise[js.Any] = js.native
}

object Router {
implicit final class RichRouter(val router: Router) extends AnyVal {
def navigateTo(name: String) = router.navigate(js.Array(name))
def navigateTo(name: String, params: (String,js.Any)*) = router.navigate(js.Array(name,js.Dictionary(params:_*)))
}
}

0 comments on commit 1851cd4

Please sign in to comment.