在角度2材质设计中,md-slide-toggle不起作用

在角度2材质设计中,md-slide-toggle不起作用

问题描述:

如何解决这个问题,我没有得到正确的输出。以下是我的代码。在角度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

的幻灯片切换看的权利,您将需要设置一个主题。有关如何使用预建主题之一开始的指南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