1

I followed all the instructions as given here: https://material.angular.io/guide/getting-started

However no material style is being applied.

In my index.html:

  <!-- material theme -->
  <link href="node_modules/@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet">
  <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">

in module.ts:

import { MaterialModule } from '@angular/material';
import 'hammerjs';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    HttpModule,
    MaterialModule.forRoot()
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

and then I have a component template as:

<form>
    <!-- title -->
    <md-input-container>
        <input md-input placeholder="Title">
    </md-input-container>
    <!-- Description -->
    <md-input-container>
        <input md-input placeholder="Description">
    </md-input-container>
    <!-- priority -->
    <md-select placeholder="Priority">
        <md-option *ngFor="let priority of priorities" >
            {{ priority }}
        </md-option>
    </md-select>
    <!-- tags -->
    <md-chip-list>
        <md-chip>UI</md-chip>
        <md-chip>Performance</md-chip>
        <md-chip>Design</md-chip>   
    </md-chip-list>


</form>

However looks like there is no theme applied, chips do not look like chips and there is no color basically.

enter image description here

What am I doing wrong?

7
  • open console/network tabs, let's check your <link href="node_modules/@angular/material/core/theming/prebuilt/indigo-pink.css" rel="stylesheet"> loaded correctly Commented Feb 5, 2017 at 12:00
  • yes it is not loaded correctly. Why? The path looks correct Commented Feb 5, 2017 at 12:03
  • did you using angular cli or another seed, if you using angular cli, just import it because angular cli won't serve node_modules folder youtu.be/0q9FOeEELPY?t=3m50s Commented Feb 5, 2017 at 12:07
  • 1
    yes I am using cli, I just added @import '~@angular/material/core/theming/prebuilt/deeppurple-amber.css'; in styles.css. and now it looks fine! Commented Feb 5, 2017 at 12:10
  • 1
    Alternatively you can put a relative link to the stylesheet in the styles array in angular-cli.json. Commented Feb 5, 2017 at 12:16

1 Answer 1

1

Guide for Angular CLI:

choose the theme you wanna use: indigo-pink, deeppurple-amber, pink-bluegrey, purple-green.

update beta.3

styles.css

@import '~@angular/material/prebuilt-themes/deeppurple-amber.c‌​ss';

styles.scss

@import '~@angular/material/prebuilt-themes/indigo-pink';

===================

styles.css

@import '~@angular/material/core/theming/prebuilt/deeppurple-amber.c‌​ss';

styles.scss

@import '~@angular/material/core/theming/prebuilt/indigo-pink';
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.