Angular2 UI-router将服务注入onExit

时间:2018-03-19 08:09:41

标签: angular

如何在UI-Router状态的MyService中将服务close()注入功能onExit?我在模块配置中使用UIRouterModule.forChild({ states: myStates })

import {MyComponent} from "../my.component";
import {MyService} from "../myservice";

export const myStates = [{
  name: 'stateName1',
  params: {
    'uid': null
  },
  views: {
    'stateName2' : {
      component : MyComponent
    }
  },
  resolve: [
    {
      token: 'data',
      deps: [MyService],
      resolveFn: resolveData
    }
  ],
  onExit: [close]
}];


export function close() {
    MyService.close();
}

0 个答案:

没有答案