This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def getObjectInstance(clsName: String): ModuleMirror = { | |
val mirror = runtimeMirror(getClass.getClassLoader) | |
val module = mirror.staticModule(clsName) | |
mirror.reflectModule(module).instance | |
} | |
def getClassInstance(clsName: String): Any = { | |
val mirror = runtimeMirror(getClass.getClassLoader) | |
val cls = mirror.classSymbol(Class.forName(clsName)) | |
val module = cls.companionSymbol.asModule |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scala.reflect.runtime.universe._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def invokeMethod(param: String) = { | |
val im =mirror.reflect(getObjectInstance("models.entities.User")) | |
val method = im.symbol.typeSignature.member(newTermName("findByUsername")).asMethod | |
im.reflectMethod(method)(param) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package models.entities | |
object User { | |
def findByUsername(username: String) = { | |
// database or whatever magic is done here ;) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en" ng-app="showcase" data-framework="typescript"> | |
<head> | |
<meta charset="utf-8"> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width"> | |
</head> | |
<body> | |
<ul class="menu"> | |
<li><a href="#/first">first</a></li> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='../_all.ts' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='libs/angular.d.ts' /> | |
/// <reference path='models/MyModel.ts' /> | |
/// <reference path='controllers/FirstCtrl.ts' />+ | |
/// <reference path='controllers/SecCtrl.ts' /> | |
/// <reference path='app.ts' /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='_all.ts' /> | |
module angularTs { | |
'use strict'; | |
var showcase = angular.module('showcase', []); | |
showcase.controller('firstCtrl', FirstCtrl.prototype.injection()); | |
showcase.controller('secCtrl', SecCtrl.prototype.injection()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='../_all.ts' /> | |
module angularTs { | |
'use strict'; | |
export class Coffee { | |
constructor( | |
public milk: Milk, | |
public size: number, | |
public name: string){} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <reference path='../_all.ts' /> | |
module angularTs { | |
'use strict'; | |
export interface IFirstScope extends ng.IScope { | |
vm: FirstCtrl; | |
} | |
export class FirstCtrl { |
OlderNewer