i'm migrating angular app typescript. i've got following ts code:
/// <reference path="../../../typings/tsd.d.ts" /> class uiroutinghelper { constructor(public $state: any) {}; reloadcurrentview() { return this.$state.go(this.$state.current.name, this.$state.params, { reload: true }); }; } mp.core.coremodule.factory('uiroutinghelper', ['$state', uiroutinghelper]); which compiles correctly. whole application build process builds correctly well. in runtime following error:
error: [$injector:undef] provider 'uiroutinghelper' must return value $get factory method. http://errors.angularjs.org/1.3.15/$injector/undef?p0=uiroutinghelper @ angular.js:63 @ object.enforcedreturnvalue [as $get] (angular.js:4058) @ object.invoke (angular.js:4203) @ angular.js:4021 @ getservice (angular.js:4162) @ object.invoke (angular.js:4194) @ extend.instance (angular.js:8493) @ angular.js:7739 @ foreach (angular.js:331) @ nodelinkfn (angular.js:7738) please advice me on doing wrong.
typings//tsd.d.ts bootstrap file, loads predefined interfaces. mp.core.coremodule has been declared before (it's available typescript).
don't use factory class. use service. code:
class uiroutinghelper { constructor(public $state: any) {}; reloadcurrentview() { return this.$state.go(this.$state.current.name, this.$state.params, { reload: true }); }; } mp.core.coremodule.service('uiroutinghelper', ['$state', uiroutinghelper]); here video on topic : https://www.youtube.com/watch?v=yis8m3bdnem
Comments
Post a Comment