我正在尝试使用材料下拉列表选择,但收到此错误:
EXCEPTION: No provider found for DomPopupSourceFactory.
materialDirectives 被添加到指令列表中,html 调用很简单:
<material-dropdown-select></material-dropdown-select>
我尝试了angular_components_example,它工作正常。问题出在我的项目上。我已经尝试清理 .packages 并执行了 pub get。什么都没用。我尝试了其他一些材料组件,它们起作用了。
如果将materialProviders
添加到AppComponent
它应该可以工作:
@Component(
selector: 'my-app',
directives: const <dynamic>[
CORE_DIRECTIVES,
materialDirectives,
],
providers: const <dynamic>[
materialProviders, // <<<<<<<<<<<<<<<<
],
)
class AppComponent {...}
它适用于angular_components示例,因为应用级组件包含必要的popupBindings
提供程序。
如果未在应用中包含materialProviders
,则可以在组件中使用更具体的提供程序。
以下是使用 material-dropdown-select
所需的最低样板:
import 'package:angular/angular.dart';
import 'package:angular_components/laminate/popup/module.dart';
import 'package:angular_components/material_select/material_dropdown_select.dart';
@Component(
selector: 'my-dropdown-select',
directives: const [
MaterialDropdownSelectComponent,
],
providers: const [
popupBindings,
],
)
class MyDropdownSelectComponent {}