Skip to content

Commit

Permalink
Merge branch 'gregghz-component-params'
Browse files Browse the repository at this point in the history
  • Loading branch information
jokade committed Oct 23, 2016
2 parents eb3a3c3 + 251f597 commit 7709770
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/main/scala/angulate2/Component.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ class Component(selector: String = null,
template: String = null,
templateUrl: String = null,
directives: js.Array[js.Any] = null,
styles: js.Array[String] = null) extends StaticAnnotation {
styles: js.Array[String] = null,
styleUrls: js.Array[String] = null) extends StaticAnnotation {
def macroTransform(annottees: Any*): Any = macro Component.Macro.impl
}

Expand All @@ -42,7 +43,8 @@ object Component {
"template",
"templateUrl",
"directives",
"styles")
"styles",
"styleUrls")

def impl(annottees: c.Expr[Any]*) : c.Expr[Any] = annottees.map(_.tree).toList match {
case (classDecl: ClassDef) :: Nil => modifiedDeclaration(classDecl)
Expand Down Expand Up @@ -123,5 +125,3 @@ object Component {

}
}


32 changes: 32 additions & 0 deletions src/main/scala/angulate2/router/ActivatedRoute.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package angulate2.router

import scala.scalajs.js
import scala.scalajs.js.|
import scala.scalajs.js.annotation.JSName
import rxjs.core.IObservable

@js.native
@JSName("ng.router.ActivatedRoute")
trait ActivatedRoute extends js.Object {
val snapshot: ActivatedRouteSnapshot = js.native
val url: IObservable[UrlPathWithParams] = js.native
val params: IObservable[js.Dynamic] = js.native
val data: IObservable[js.Any] = js.native
val outlet: String = js.native
val component: js.Any = js.native
}

@js.native
trait ActivatedRouteSnapshot extends js.Object {
val url: js.Array[UrlPathWithParams] = js.native
val params: js.Dynamic = js.native
val data: js.Any = js.native
val outlet: String = js.native
val component: js.Any = js.native
}

@js.native
trait UrlPathWithParams extends js.Object {
val path: String = js.native
val parameters: Map[String, String] = js.native
}
6 changes: 6 additions & 0 deletions src/main/scala/angulate2/router/RouteDefinition.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ object RDef {
def apply(path: String = null,
name: String = null,
component: JSType = null,
redirectTo: js.UndefOr[String] = js.undefined,
pathMatch: js.UndefOr[String] = js.undefined,
useAsDefault: Boolean = false) : RouteDefinition = {
val d = js.Dynamic.literal()
if(path!=null)
Expand All @@ -30,6 +32,10 @@ object RDef {
d.name = name
if(component!=null)
d.component = component

redirectTo.foreach(d.redirectTo = _)
pathMatch.foreach(d.pathMatch = _)

d.useAsDefault = useAsDefault
d.asInstanceOf[RouteDefinition]
}
Expand Down
14 changes: 14 additions & 0 deletions src/main/scala/angulate2/router/RouterConfig.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package angulate2.router

import scala.scalajs.js
import scala.scalajs.js.annotation.JSName

@js.native
@JSName("ng.router.RouterConfig")
trait RouterConfig extends js.Object

object RouterConfig {
def apply(defs: RouteDefinition*): RouterConfig = {
js.Array(defs: _*).asInstanceOf[RouterConfig]
}
}

0 comments on commit 7709770

Please sign in to comment.