Permalink
Browse files

this 在 class 內使用 arrow function 第一種方法

  • Loading branch information...
1 parent fad393c commit 465c28b27dc74d1570e9e7a4553ac17d3c61178a Sam.IO.Hsiao committed Nov 5, 2016
Showing with 34 additions and 0 deletions.
  1. +17 −0 this_class_arrow_function1.js
  2. +1 −0 this_class_arrow_function1.js.map
  3. +16 −0 this_class_arrow_function1.ts
@@ -0,0 +1,17 @@
+var MyModule;
+(function (MyModule) {
+ var Foo = (function () {
+ function Foo(name) {
+ var _this = this;
+ this.say = function () {
+ console.log("Hello, " + _this.name);
+ };
+ this.name = name;
+ }
+ return Foo;
+ }());
+ MyModule.Foo = Foo;
+})(MyModule || (MyModule = {}));
+var foo = new MyModule.Foo('Sam');
+setTimeout(foo.say, 1000);
+//# sourceMappingURL=this_class_arrow_function1.js.map
@@ -0,0 +1 @@
+{"version":3,"file":"this_class_arrow_function1.js","sourceRoot":"","sources":["this_class_arrow_function1.ts"],"names":[],"mappings":"AAAA,IAAO,QAAQ,CAYd;AAZD,WAAO,QAAQ,EAAC,CAAC;IACb;QAGI,aAAY,IAAY;YAH5B,iBAUC;YAHU,QAAG,GAAa;gBACnB,OAAO,CAAC,GAAG,CAAC,YAAU,KAAI,CAAC,IAAM,CAAC,CAAA;YACtC,CAAC,CAAC;YALE,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACrB,CAAC;QAKL,UAAC;IAAD,CAAC,AAVD,IAUC;IAVY,YAAG,MAUf,CAAA;AACL,CAAC,EAZM,QAAQ,KAAR,QAAQ,QAYd;AAED,IAAI,GAAG,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AAClC,UAAU,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC"}
@@ -0,0 +1,16 @@
+module MyModule {
+ export class Foo {
+ private name: string;
+
+ constructor(name: string) {
+ this.name = name;
+ }
+
+ public say: ()=>void = ()=> {
+ console.log(`Hello, ${this.name}`)
+ };
+ }
+}
+
+var foo = new MyModule.Foo('Sam');
+setTimeout(foo.say, 1000);

0 comments on commit 465c28b

Please sign in to comment.