Angular Dart passing data from route service into a controller

二次信任 提交于 2019-12-04 19:55:56

Why do you want to do this in the route enter event handler?
You don't even use any information from the route or the event.
You could just register the UserService with your Module an let it inject to your UserController.

class MyAppModule extends Module {
  MyAppModule() {
    type(UsersService);
  }
}

@NgController(
  selector: '[users-controller]',
  publishAs: 'userCtrl'
)

class UsersController {
  var list;

  UsersService _usersService;

  UsersController(this._usersService) {
    _userService.all((HttpResponse response){
                    var data = response.data['body'];
                    print(data);
  }
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!