【发布时间】:2019-09-04 19:31:49
【问题描述】:
我想在 Angular dart 上通过 Web 应用程序进行 GET,但是当我尝试使用应用程序打开页面时,控制台出现错误:
Uncaught Error: Invalid argument(s): No provider found for Client0.
还有这个入口点
void main() {
bootstrap(AppComponent, [BrowserClient]);
}
而且我只有一个来自 Web Storm 的组件和一个默认组件,因为我使用了来自 Web Storm 的AngularDart Web App - a web app with material design component 模板:
@Component(
selector: 'watch-counter',
styleUrls: const [
'package:angular_components/app_layout/layout.scss.css',
'watch_counter_component.css'],
templateUrl: 'watch_counter_component.html',
directives: const [
CORE_DIRECTIVES,
materialDirectives,
],
providers: const [UserService]
)
class WatchCounterComponent implements OnInit {
final UserService userService;
WatchCounterComponent(this.userService);
int tabIndex = 0;
void onTabChange(TabChangeEvent event) {
tabIndex = event.newIndex;
}
final loginModalTabs = const<String>[
'Login',
'Registration'
];
@override
Future<Null> ngOnInit() async {
}
}
有了这项服务
@Injectable()
class UserService {
final Client http;
UserService(this.http);
dynamic extractData(Response resp) => JSON.decode(resp.body)['data'];
Future login(String login, String password) async {
print("login");
}
void register() {
print("register");
}
}
当我将 http 客户端添加到服务中时的所有失败。
【问题讨论】:
-
这些信息不足以提供帮助。您能否提供一个更完整的失败代码示例,而不仅仅是上面的几行代码?
-
@matanlurey 谢谢,我添加了更多细节。我真的不明白什么问题
标签: javascript angular dart