gpt4 book ai didi

asp.net-mvc - 在 Visual Studio 2013 中使用 AngularJS Material 设计

转载 作者:行者123 更新时间:2023-12-02 04:10:05 27 4
gpt4 key购买 nike

我是 angularjs Material 设计的新手,希望在我的前端实现其丰富的 UI 功能。 VS13 附带安装在创建的模板中的 Bootstrap 。我可以将 angularjs Material 设计与 bootstrap 结合起来或自定​​义 bootstrap 来为我提供 Material 设计外观和动画吗?

我创建了新项目并安装了 angularjs material design ,将其添加到 BondleConfig.vbApp_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到它。另外,使用像 <md-button></md-button> 这样的标签在 html 标记中给出 unknown element错误。

最佳答案

您的 bundle 配置看起来不错,只是您忘记在 bundle 中包含 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com