Angular Material的使用详解


本文摘自PHP中文网,作者php中世界最好的语言,侵删。

这次给大家带来Angular Material的使用详解,Angular Material使用的注意事项有哪些,下面就是实战案例,一起来看一下。

使用方法

用npm下载angular-material、angular-aria、angular-animate

代码如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

<!DOCTYPE html><html lang="en"><head>

    <meta charset="UTF-8">

    <title>Document</title>

       

    <link rel="stylesheet" href="node_modules/angular-material/angular-material.css"></head><body ng-app="myApp" ng-controller="myCtrl" layout="column">

      <md-toolbar>   

      <h3>Angular Material 演示代码</h3>

    </md-toolbar>

    <div class="container" layout="row" flex>

        <md-sidenav md-is-locked-open="true" class="md-whiteframe-z2">

          <md-list>

            <md-list-item ng-repeat="item in arr">

                <md-button ng-click="toggle($index)">

                  {{item.title}}                </md-button>

            </md-list-item>

          </md-list>

        </md-sidenav>

        <md-content flex id="content" class="lightgreen" flex>

          <h2>{{rightTitle}}</h2>

          <p>

            {{rightCont}}          </p>

          <md-checkbox ng-model="isChecked" aria-label="Finished?">

          Finished ?        </md-checkbox>

        <md-checkbox md-no-ink ng-model="hasInk" aria-label="No Ink Effects">

          No Ink Effects        </md-checkbox>

        <md-checkbox ng-disabled="true" ng-model="isDisabled" aria-label="Disabled">

          Disabled        </md-checkbox>

        <form name="colorForm">

  <md-input-container>

    <label>Favorite Color</label>

    <input name="favoriteColor" ng-model="favoriteColor" required>

    <div ng-messages="colorForm.favoriteColor.$error">

      <div ng-message="required">This is required!</div>

    </div>

  </md-input-container></form><md-progress-circular md-mode="determinate" value="80"></md-progress-circular><md-progress-circular md-mode="determinate" ng-value="60"></md-progress-circular><md-progress-circular md-mode="determinate" value="50" md-diameter="100"></md-progress-circular><md-progress-circular md-mode="indeterminate"></md-progress-circular><md-button class="md-fab md-accent" aria-label="Play">

  <md-tooltip>

    Play Music  </md-tooltip></md-button><div md-whiteframe="3">

  <span>Elevation of 3dp</span></div>

        </md-content>

             

         

    </div>

    <script src="node_modules/angular/angular.min.js"></script>

    <script src="node_modules/angular-animate/angular-animate.min.js"></script>

    <script src="node_modules/angular-aria/angular-aria.min.js"></script>

    <script src="node_modules/angular-material/angular-material.js"></script>

    <script>

        var myApp = angular.module('myApp',['ngMaterial']);

        myApp.controller('myCtrl',['$scope',function($scope){

            $scope.arr = [

                {title:'标题1',cont:'内容1'},

                {title:'标题2',cont:'内容2'},

                {title:'标题3',cont:'内容3'},

                {title:'标题4',cont:'内容4'}

            ];

             

            $scope.toggle = function(id){

                $scope.rightTitle = $scope.arr[id].title;

                $scope.rightCont = $scope.arr[id].cont;

            };

            $scope.rightTitle = $scope.arr[0].title;

            $scope.rightCont = $scope.arr[0].cont;

        }]);    </script></body></html>

1.png

阅读剩余部分

相关阅读 >>

如何利用管道提高angular应用程序的性能?

dw文本框制作步骤详解

如何安装和使用angular cli?(图文详解)

浅谈angular中插槽的用法

angular入门学习之环境和项目的搭建

深入了解angular中的pipe(管道)

详解angular中的依赖注入模式

详解angular中的组件交互

angular中的firebase身份验证(代码示例)

了解一下angular中的@input()和@output()

更多相关阅读请进入《Material》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...