คราวนี้เอาหัวโขกกำแพงเลย ฉันได้รับข้อผิดพลาดเมื่อเรียกใช้แอป เชิงมุม 2 โดยใช้ SystemJS และวัสดุเชิงมุม ไม่เข้าใจว่าทำไม ฉันกำลังใช้โครงการ Angular-seed: https://github.com/mgechev/angular-seed ก>. ฉันเพิ่มเนื้อหาผ่านแนวทางนี้: https://github.com/mgechev/angular-seed/wiki/Integration-with-AngularMaterial2.
ข้อผิดพลาด:
Unhandled Promise rejection: Template parse errors:
'md-toolbar' is not a known element:
home.component.html
<md-toolbar>Test</md-toolbar>
การกำหนดค่า SystemJS
this.NPM_DEPENDENCIES = [
...this.NPM_DEPENDENCIES,
{src: '@angular/material/core/theming/prebuilt/indigo-pink.css', inject: true}
// {src: 'jquery/dist/jquery.min.js', inject: 'libs'},
// {src: 'lodash/lodash.min.js', inject: 'libs'},
];
this.addPackageBundles({
name:'@angular/material',
path:'node_modules/@angular/material/bundles/material.umd.js',
packageMeta:{
main: 'index.js',
defaultExtension: 'js'
}
});
โปรดทราบว่าดูเหมือนว่าไฟล์กำลังโหลดในเบราว์เซอร์เมื่อตรวจสอบแหล่งที่มาด้วยเครื่องมือ dev
โมดูลแอป
...
import { MaterialModule } from '@angular/material';
@NgModule({
imports: [BrowserModule, HttpModule, MaterialModule.forRoot(), AppRoutingModule, AboutModule, HomeModule, SharedModule.forRoot()],
...
package.json
"dependencies": {
"@angular/common": "~2.4.0",
"@angular/compiler": "~2.4.0",
"@angular/core": "~2.4.0",
"@angular/forms": "~2.4.0",
"@angular/http": "~2.4.0",
"@angular/material": "^2.0.0-beta.2",
"@angular/platform-browser": "~2.4.0",
"@angular/platform-browser-dynamic": "~2.4.0",
"@angular/router": "~3.4.1",
"core-js": "^2.4.1",
"intl": "^1.2.5",
"rxjs": "~5.0.3",
"systemjs": "0.19.41",
"zone.js": "^0.7.4"
}
...
ส่วนประกอบภายในบ้าน
import { Component, OnInit } from '@angular/core';
import { NameListService } from '../shared/name-list/name-list.service';
/**
* This class represents the lazy loaded HomeComponent.
*/
@Component({
moduleId: module.id,
selector: 'sd-home',
templateUrl: 'home.component.html',
styleUrls: ['home.component.css'],
})
export class HomeComponent implements OnInit {
...
ถาม - ฉันจะแก้ไขปัญหาองค์ประกอบที่ไม่รู้จักนี้ได้อย่างไร ขอบคุณ!
package.json
เวอร์ชันวัสดุของคุณ - person kind user   schedule 25.02.2017MaterialModule
เท่านั้น แทนที่จะเป็นMaterialModule.forRoot()
และตรวจสอบ - person micronyks   schedule 25.02.2017