Sử dụng angular2-beta12 và ng2 vật chất 0.3.4
Tôi đã có vấn đề nhận được ng2 vật chất để làm việc là tốt.
Điều đầu tiên tôi bị thiếu trong tệp index.html đã khai báo css.
<link rel="stylesheet" href="node_modules/ng2-material/dist/ng2-material.css">
<link rel="stylesheet" href="node_modules/ng2-material/dist/font.css">
Sau đó, một trong những điều quan trọng tôi thấy là thiếu thông tin bản đồ được lồng trong khung gói. Khi tôi chuyển nó bên ngoài tuyên bố System.config của tôi trông như thế này:
index.html
System.config({
packages: {
app: {
format: 'register',
defaultExtension: 'js'
},
'ng2-material': {//this needs to be nested in packages
defaultExtension: 'js'
}
},
map: {//The map location needs to be located outside of the package bracket
'ng2-material': 'node_modules/ng2-material'
}
});
System.import('app/main')
.then(null, console.error.bind(console));
Sau đó, trong main.ts tôi nộp tôi nhập MATERIAL_PROVIDERS
Main.ts
import {MATERIAL_PROVIDERS} from "ng2-material/all";
import {AppComponent} from './app.component'
bootstrap(AppComponent, [MATERIAL_PROVIDERS]);
Cuối cùng trên thành phần muốn sử dụng vật liệu ng2 trên I impor ted MATERIAL_DIRECTIVES
create.component.ts
import {Component} from 'angular2/core';
import {RouterOutlet} from 'angular2/router';
import {MATERIAL_DIRECTIVES} from "ng2-material/all";
@Component({
templateUrl: 'app/templates/create.html',
directives: [RouterOutlet, MATERIAL_DIRECTIVES]
})
export class CreateComponent {...component code}
Nguồn
2016-03-31 01:56:53
Hệ thống.cấu hình ({ \t \t gói: {app: {định dạng: 'đăng ký', defaultExtension: 'js'}} \t \t \t \t}); System.import ('ứng dụng/khởi động') .then (null, console.error.bind (console)); cách tải tệp ứng dụng/khởi động? –