【发布时间】:2016-09-04 06:07:12
【问题描述】:
当我使用 mdIcon 时,Angular 会抛出一个错误。下面是代码:
import {Component} from '@angular/core';
import {MdIcon} from '@angular2-material/icon';
@Component({
selector: 'my-app',
template: `
<md-toolbar>
<md-icon class="demo-toolbar-icon">menu</md-icon>
<span>Default Toolbar</span>
<span class="demo-fill-remaining"></span>
<md-icon>code</md-icon>
</md-toolbar>`,
directives: [MdIcon,MdToolbar],
})
export class AppComponent {}
错误:
原始例外:没有 MdIconRegistry 的提供者! 错误:DI 异常 在 NoProviderError.BaseException [作为构造函数] (exceptions.ts:14) 在 NoProviderError.AbstractProviderError [作为构造函数] (reflective_exceptions.ts:53) 在新的 NoProviderError (reflective_exceptions.ts:85) 在 ReflectiveInjector_._throwOrNull (reflective_injector.ts:844) 在 ReflectiveInjector_._getByKeyDefault (reflective_injector.ts:873) 在 ReflectiveInjector_._getByKey (reflective_injector.ts:835) 在 ReflectiveInjector_.get (reflective_injector.ts:632) 在 ElementInjector.get (element_injector.ts:19) 在 DebugAppView._View_AppComponent0.createInternal (AppComponent.template.js:141) 在 DebugAppView.AppView.create (view.ts:110)
谁能帮我看看我做错了什么?
【问题讨论】:
标签: angular typescript angular-material