[英]How can I use angular material with angular 2?
我已經嘗試過npm install angular-material --save
並按照這里的說明進行操作。
然后我添加了腳本並鏈接到index.html
<script src="node_modules/angular-material/index.js"></script>
<link ref="stylesheet" href="node_modules/angular-material/modules/angular-material.css">
然后我嘗試添加一個簡單的<md-button>
但是沒有運氣。
由於這個問題是寫的,Angular團隊創建了“Angular 2的Material Design”github項目: https : //github.com/angular/material2
有關安裝說明,請參閱“ 入門指南” 。
他們希望您(安裝和)使用Angular CLI 。
由於這兩個項目目前都處於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}
另一種方法是使用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>
因此你可以使用材料設計ex:
<label>
<input type="checkbox" />
<span>Red</span>
</label>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.