简体   繁体   English

如何使用角度为2的角度材料?

[英]How can I use angular material with angular 2?

I've tried npm install angular-material --save and followed the instructions here. 我已经尝试过npm install angular-material --save并按照这里的说明进行操作。

Then I added the script and link to index.html 然后我添加了脚本并链接到index.html

<script src="node_modules/angular-material/index.js"></script>
<link ref="stylesheet" href="node_modules/angular-material/modules/angular-material.css">

Then I tried adding a simple <md-button> but am having no luck. 然后我尝试添加一个简单的<md-button>但是没有运气。

Since this question was written, the Angular team has created the "Material Design for Angular 2" github project: https://github.com/angular/material2 由于这个问题是写的,Angular团队创建了“Angular 2的Material Design”github项目: https//github.com/angular/material2

See the Getting Started guide for installation instructions. 有关安装说明,请参阅“ 入门指南”

They want you to (install and) use the Angular CLI . 他们希望您(安装和)使用Angular CLI

Since both projects are currently in alpha, the instructions below may change over time: 由于这两个项目目前都处于alpha状态,因此以下说明可能会随时间而变化:

# install the CLI globally
npm install -g angular-cli

# create a new project
ng new my-project

# install Angular Material 2 components
npm install --save @angular2-material/{core,button,card}

An alternative is use materialize from https://materializecss.com You just import this files into your index.html that is in src folder 另一种方法是使用https://materializecss.com中的 materialise。您只需将此文件导入到src文件夹中的index.html中

<!-- Compiled and minified CSS -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/css/materialize.min.css">

    <!-- Compiled and minified JavaScript -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0-beta/js/materialize.min.js"></script>

thus you can use material design ex: 因此你可以使用材料设计ex:

 <label>
    <input type="checkbox" />
    <span>Red</span>
  </label>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM