当我使用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 {}
Run Code Online (Sandbox Code Playgroud)
错误:
原始例外:没有MdIconRegistry的提供者!错误: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),ReflexInjector_.get(reflective_injector.ts:632),位于ElementInjector.get(element_injector.ts:19)at DebugAppView.AppView.create中的DebugAppView._View_AppComponent0.createInternal(AppComponent.template.js:141)(view.ts:110)
谁能帮助我,我在这里做错了什么?
当我在Hero.service.ts中使用get url作为web api时,在浏览器控制台中出现以下错误.但是当我在一个项目中使用.Json文件时它工作正常,因为我能够在输出页面中看到值.我刚刚在angular.io网站上学习.
以下是控制台中的错误:
angular2-polyfills.js:471 Error: Uncaught (in promise): EXCEPTION: Error: unable to parse url 'http://md5.jsontest.com/?text=example_text'; original error: Cannot read property 'split' of undefined in [null](…)consoleError @ angular2-polyfills.js:471
Get url: http://md5.jsontest.com/?text=example_text
Run Code Online (Sandbox Code Playgroud)
这是完整的代码,
你能帮我解决一下我在做错的事吗?
我对如何配置这个system-config.ts感到困惑,现在我试图将材料2代码包含在Angular快速启动包中,但它没有用.
在material2 github中,它显示需要在system-config.ts中添加以下配置,但无法找到解决方案.以下是material2依赖项.
// The core package is required as a peerDependency for other components.
'@angular2-material/core': {
format: 'cjs',
defaultExtension: 'js',
main: 'core.js'
},
'@angular2-material/checkbox': {
format: 'cjs',
defaultExtension: 'js',
main: 'checkbox.js'
},//
Run Code Online (Sandbox Code Playgroud)
在angular2快速启动中,它看起来如下所示,
(function(global) {
// map tells the System loader where to look for things
var map = {
'app': 'app', // 'dist',
'rxjs': 'node_modules/rxjs',
'angular2-in-memory-web-api': 'node_modules/angular2-in-memory-web-api',
'@angular': 'node_modules/@angular'
};
// packages tells the System loader how to load when no filename and/or no extension
var packages = …Run Code Online (Sandbox Code Playgroud) 我正在学习angular2和material2.我正在尝试制作具有简单工具栏和固定sidenav的小型网站.我创建了工具栏,但sidenav没有按预期工作.我只是使用下面的plunker代码进行学习.
<md-toolbar color="primary">
Angular Material 2 App
</md-toolbar>
<md-sidnav-layout>
<md-sidenav>
<md-nav-list>
<a md-list-item>
Test1
</a>
</md-nav-list>
</md-sidenav>
</md-sidnav-layout>
Run Code Online (Sandbox Code Playgroud)
你能帮我创建一个固定的导航栏吗?还是我做错了什么?我正在遵循angular/material2代码.