我是angularjs Material 设计的新手,希望在我的前端实现其丰富的UI功能。 VS13在创建的模板中安装了 bootstrap 。我可以将angularjs Material 设计与 bootstrap 结合使用还是可以自定义 bootstrap ,以便为我提供 Material 设计外观和动画?
我创建了新项目并安装了angularjs material design
,并将其添加到BondleConfig.vb
文件夹下的App_Start
中
bundles.Add(New ScriptBundle("~/bundles/angular").Include(
"~/bundles/angular.js",
"~/bundles/angular-animate.js",
"~/bundles/angular-aria.js"))
bundles.Add(New StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/angular-material/angular-material.css",
"~/Content/site.css"))
我能够将
class="md-button md-raised"
添加到一个链接,该链接为我提供了一个不错的凸起按钮,但我无法为其添加md-primary
。此外,在html标记中使用<md-button></md-button>
之类的标签也会产生unknown element
错误。 最佳答案
您的捆绑包配置看起来不错,只是您忘记在捆绑包中包含angular-material.js。
bundles.Add(New ScriptBundle("~/bundles/angular").Include(
"~/bundles/angular.js",
"~/bundles/angular-animate.js",
"~/bundles/angular-aria.js",
"~/bundles/angular-material.js")) //missing part
bundles.Add(New StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/angular-material/angular-material.css",
"~/Content/site.css"))
您还必须在配置中包含一个app.js文件(*)。
您的配置必须具有模块和 Controller 。
关键部分是dependency injection。您必须包含ngMaterial模块才能使用下载的库...
并且不要忘记包含其他脚本!
//(*) app.js
angular.module('MyApp',['ngMaterial'])
.controller('AppCtrl', function($scope) {
$scope.title1 = 'Button';
$scope.title4 = 'Warn';
$scope.isDisabled = true;
$scope.googleUrl = 'http://google.com';
});
.buttondemoBasicUsage section {
background: #f7f7f7;
border-radius: 3px;
text-align: center;
margin: 1em;
position: relative !important;
padding-bottom: 10px; }
.buttondemoBasicUsage md-content {
margin-right: 7px; }
.buttondemoBasicUsage section .md-button {
margin-top: 16px;
margin-bottom: 16px; }
.buttondemoBasicUsage .label {
position: absolute;
bottom: 5px;
left: 7px;
font-size: 14px;
opacity: 0.54; }
<link href="http://cdn.rawgit.com/angular/bower-material/v0.10.0/angular-material.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-animate.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-route.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-aria.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular-messages.min.js"></script>
<script src="http://cdn.rawgit.com/angular/bower-material/v0.10.0/angular-material.js"></script>
<script src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-114/assets-cache.js"></script>
<div ng-controller="AppCtrl" class="buttondemoBasicUsage" ng-app="MyApp">
<md-content>
<section layout="row" layout-sm="column" layout-align="center center">
<md-button>{{title1}}</md-button>
<md-button md-no-ink="" class="md-primary">Primary (md-noink)</md-button>
<md-button ng-disabled="true" class="md-primary">Disabled</md-button>
<md-button class="md-warn">{{title4}}</md-button>
<div class="label">Flat</div>
</section>
<section layout="row" layout-sm="column" layout-align="center center">
<md-button class="md-raised">Button</md-button>
<md-button class="md-raised md-primary">Primary</md-button>
<md-button ng-disabled="true" class="md-raised md-primary">Disabled</md-button>
<md-button class="md-raised md-warn">Warn</md-button>
<div class="label">Raised</div>
</section>
<section layout="row" layout-sm="column" layout-align="center center">
<md-button ng-href="{{googleUrl}}" target="_blank">Default Link</md-button>
<md-button class="md-primary" ng-href="{{googleUrl}}" target="_blank">Primary Link</md-button>
<md-button>Default Button</md-button>
<div class="label">Link vs. Button</div>
</section>
<section layout="row" layout-sm="column" layout-align="center center">
<md-button class="md-primary md-hue-1">Primary Hue 1</md-button>
<md-button class="md-warn md-raised md-hue-2">Warn Hue 2</md-button>
<md-button class="md-accent">Accent</md-button>
<md-button class="md-accent md-raised md-hue-1">Accent Hue 1</md-button>
<div class="label">Themed</div>
</section>
</md-content>
</div>
我还遵循了这个example,向您展示了它是如何工作的。
我希望现在还可以:)
关于asp.net-mvc - 在Visual Studio 2013中使用angularjs Material 设计,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/31222310/