2016-12-16 117 views
0

如何解決這個問題,我沒有得到正確的輸出。以下是我的代碼。在角度2材質設計中,md-slide-toggle不起作用

這是應用程序組件。

import { Component } from '@angular/core'; 

    @Component({ 
     selector: 'app-root', 
     template: ` 
     <md-slide-toggle> 
     Slide Toggle 
     </md-slide-toggle> 
     `, 
     styleUrls: ['./app.component.css'] 
    }) 

    export class AppComponent { 



    } 

我已經安裝了這些配置。

npm install --save @angular/material 

    npm install --save hammerjs 

    npm install --save-dev @types/hammerjs 

    but how to configure this in system js(I am using cli to generate project and was not able to find systemjs file). 

    System.config({ 
     // existing configuration options 
     map: { 
     ..., 
     '@angular/material': 'npm:@angular/material/material.umd.js' 
     } 
    }); 

見下圖

This image is output

回答

0

的幻燈片切換看的權利,您將需要設置一個主題。有關如何使用預建主題之一開始的指南here

+0

zone.js:1382GET http:// localhost:4200/[email protected]/material/core/theming/prebuilt/deeppurple-amber.css 404(Not Found) – sumeeth

+0

當我添加deeppurple-amber.css到應用程序。 component.css它顯示404未找到錯誤。 zone.js:1382GET http:// localhost:4200/[email protected]/material/core/theming/prebuilt/deeppurple-amber.css 404(未找到) – sumeeth

+0

如果您正在使用angular-cli移動,最好移動deeppurple-amber.scss到src文件夾中。將文件第一行的import語句更改爲'@import'〜@ angular/material/core/theming/all-theme';'。然後將該文件添加到angular-cli.json的樣式部分。主題將由cli構建。 – JayChase