Using angular2-beta12 and ng2 material 0.3.4
I'm having trouble working with ng2 stuff.
The first thing I lost in my index.html file was declaring css.
<link rel="stylesheet" href="node_modules/ng2-material/dist/ng2-material.css"> <link rel="stylesheet" href="node_modules/ng2-material/dist/font.css">
After that, one of the important things that I found that I was missing was the map information nested inside the package bracket. As soon as I moved it outside of my System.config statement, it looks like this:
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));
Then in my main.ts file I import MATERIAL_PROVIDERS
Main.ts
import {MATERIAL_PROVIDERS} from "ng2-material/all"; import {AppComponent} from './app.component' bootstrap(AppComponent, [MATERIAL_PROVIDERS]);
Finally, on a component that wants to use ng2 material, I imported 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}
M.Bland
source share