{"action":"created","issue":{"url":"https://api.github.com/repos/mgechev/angular-aop/issues/13","labels_url":"https://api.github.com/repos/mgechev/angular-aop/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/mgechev/angular-aop/issues/13/comments","events_url":"https://api.github.com/repos/mgechev/angular-aop/issues/13/events","html_url":"https://github.com/mgechev/angular-aop/issues/13","id":57677489,"number":13,"title":"Typescript: undefined is not a function","user":{"login":"elsom25","id":542544,"avatar_url":"https://avatars.githubusercontent.com/u/542544?v=3","gravatar_id":"","url":"https://api.github.com/users/elsom25","html_url":"https://github.com/elsom25","followers_url":"https://api.github.com/users/elsom25/followers","following_url":"https://api.github.com/users/elsom25/following{/other_user}","gists_url":"https://api.github.com/users/elsom25/gists{/gist_id}","starred_url":"https://api.github.com/users/elsom25/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elsom25/subscriptions","organizations_url":"https://api.github.com/users/elsom25/orgs","repos_url":"https://api.github.com/users/elsom25/repos","events_url":"https://api.github.com/users/elsom25/events{/privacy}","received_events_url":"https://api.github.com/users/elsom25/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-02-14T02:24:06Z","updated_at":"2015-02-17T17:54:58Z","closed_at":"2015-02-17T08:15:48Z","body":"I've been trying to integrate aop for logging, and followed both the `README` and a [post you've made](https://groups.google.com/d/msg/angular/5dv-LjNRgDc/mz6MW7oySR0J), with no luck.\r\n\r\nMy typescript:\r\n\r\n```typescript\r\n/// <reference path=\"/typings/angularjs/angular.d.ts\" />\r\n\r\ninterface Window { TEST : any; }\r\n\r\nmodule MyApp {\r\n  \"use strict\";\r\n\r\n  export function boot(\r\n    $log : ng.ILogService\r\n  ) {\r\n    $log.info(\"starting\");\r\n  }\r\n\r\n  angular\r\n    .module(\"my_app\", [\r\n      \"uuid4\",\r\n      \"ngTouch\",\r\n      \"AngularAOP\"\r\n    ])\r\n    .factory(\"log_aspect\", [() => {\r\n      return (data : any) => {\r\n        console.log(\"==== HELLO ====\");\r\n        console.log(data);\r\n      };\r\n    }])\r\n    .factory(\"DummyService\", [() => {\r\n      return {\r\n        foo: () => { console.log(\"---- foo ----\"); },\r\n        bar: (a : any, b : any) => {\r\n          console.log(\"---- bar ----\", a, b);\r\n          return a * b;\r\n        }\r\n      };\r\n    }])\r\n    .controller(\"BusController\", [\r\n      \"DummyService\",\r\n      (DummyService : any) => {\r\n        DummyService.foo();\r\n        DummyService.bar(2, 3.14);\r\n      }\r\n    ])\r\n    .config( ($provide : any, executeProvider : any) => {\r\n      executeProvider.annotate($provide, {\r\n        DummyService: [{\r\n          jointPoint: \"after\",\r\n          advice: \"log_aspect\"\r\n        }]\r\n      });\r\n    })\r\n    .run([\r\n      \"$log\",\r\n      window.TEST ? () => {} : boot\r\n    ]);\r\n}\r\n```\r\n\r\nand compiled js:\r\n\r\n```js\r\nvar MyApp;\r\n(function (MyApp) {\r\n    \"use strict\";\r\n    function boot($log) {\r\n        $log.info(\"starting\");\r\n    }\r\n    MyApp.boot = boot;\r\n    angular.module(\"my_app\", [\r\n        \"uuid4\",\r\n        \"ngTouch\",\r\n        \"AngularAOP\"\r\n    ]).factory(\"log_aspect\", [function () {\r\n        return function (data) {\r\n            console.log(\"==== HELLO ====\");\r\n            console.log(data);\r\n        };\r\n    }]).factory(\"DummyService\", [function () {\r\n        return {\r\n            foo: function () {\r\n                console.log(\"---- foo ----\");\r\n            },\r\n            bar: function (a, b) {\r\n                console.log(\"---- bar ----\", a, b);\r\n                return a * b;\r\n            }\r\n        };\r\n    }]).controller(\"BusController\", [\r\n        \"DummyService\",\r\n        function (DummyService) {\r\n            DummyService.foo();\r\n            DummyService.bar(2, 3.14);\r\n        }\r\n    ]).config(function ($provide, executeProvider) {\r\n        executeProvider.annotate($provide, {\r\n            DummyService: [{\r\n                jointPoint: \"after\",\r\n                advice: \"log_aspect\"\r\n            }]\r\n        });\r\n    }).run([\r\n        \"$log\",\r\n        window.TEST ? function () {\r\n        } : boot\r\n    ]);\r\n})(MyApp || (MyApp = {}));\r\n```\r\n\r\nwith console output:\r\n\r\n```\r\n TypeError: undefined is not a function\r\n    at Object.AspectBuilder._getFunctionAspect (main.js:11417)\r\n    at Object.AspectBuilder._getObjectAspect (main.js:11434)\r\n    at AspectCollection.AspectBuilder.buildAspect [as after] (main.js:11412)\r\n    at main.js:11392\r\n    at Object.invoke (main.js:3944)\r\n    at Object.origProvider.$get (main.js:3896)\r\n    at Object.invoke (main.js:3944)\r\n    at main.js:3974\r\n    at getService (main.js:3930)\r\n    at Object.invoke (main.js:3942)\r\n```\r\n\r\nIf there's any help you can provide it would be greatly appreciated! Really want to integrate this~\r\n\r\n---\r\n2015-02-14: Edited to port full typescript and compiled js"},"comment":{"url":"https://api.github.com/repos/mgechev/angular-aop/issues/comments/74715916","html_url":"https://github.com/mgechev/angular-aop/issues/13#issuecomment-74715916","issue_url":"https://api.github.com/repos/mgechev/angular-aop/issues/13","id":74715916,"user":{"login":"mgechev","id":455023,"avatar_url":"https://avatars.githubusercontent.com/u/455023?v=3","gravatar_id":"","url":"https://api.github.com/users/mgechev","html_url":"https://github.com/mgechev","followers_url":"https://api.github.com/users/mgechev/followers","following_url":"https://api.github.com/users/mgechev/following{/other_user}","gists_url":"https://api.github.com/users/mgechev/gists{/gist_id}","starred_url":"https://api.github.com/users/mgechev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mgechev/subscriptions","organizations_url":"https://api.github.com/users/mgechev/orgs","repos_url":"https://api.github.com/users/mgechev/repos","events_url":"https://api.github.com/users/mgechev/events{/privacy}","received_events_url":"https://api.github.com/users/mgechev/received_events","type":"User","site_admin":false},"created_at":"2015-02-17T17:54:58Z","updated_at":"2015-02-17T17:54:58Z","body":"It is not necessary to use `factory` instead of `service`, but you should use `service` the right way. `service` accepts a function, which is later invoked with `new`. The result is being cached internally in the `provider`."}}