简体   繁体   中英

How to display md-button as md-raised using AngularJS Material

I am trying to have my buttons styled with AngularJS Material. Specifically, I want to use md-button with class md-raised.

However, when I try this my button looks like regular text rather than an md-button. What could I be doing wrong?

Here is my index.html where I am trying to place the button.

<!doctype html>
<html>
<head>
    <!--Angular scripts-->
    <link href="./node_modules/angular-material/angular-material.css" rel="stylesheet" />
    <script src="./node_modules/angular/angular.js" type="text/javascript" ></script>
    <script src="./node_modules/angular-animate/angular-animate.js" type="text/javascript" ></script>
    <script src="./node_modules/angular-aria/angular-aria.js" type="text/javascript" ></script>
    <script src="./node_modules/angular-material/angular-material.js" type="text/javascript" ></script>
    <script src="node_modules/angular-route/angular-route.js"></script>
    <script src="node_modules/angular-resource/angular-resource.js"></script>
    <script src="mainController.js"></script>
</head>
<body>
    <md-button class="md-raised">Button</md-button>
</body>

The reason why it didn't appear is because you forgot to initialize your app!

 // Initialize your app here and add `ngMaterial` dependency angular.module('App', ['ngMaterial']); 
 <!-- Also add your ng-app directive --> <html ng-app="App"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-animate.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-aria.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.11/angular-messages.min.js"></script> <script src="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.4/angular-material.min.js"></script> <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/1.1.4/angular-material.min.css"> </head> <body> <md-button class="md-raised">Test</md-button> </body> </html> 

I was able to accomplish this by adding

    <div class="md-button md-raised">
        <p>Button</p>
    </div>

instead of

<md-button class="md-raised">Button</md-button>

I'm not sure why this works though, and any feedback would be greatly appreciated.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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