• angular 入门


    入门

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
        </head>
        
        <body ng-app>
            {{100+100}}
        </body>
    </html>

    双向绑定

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
        </head>
        <body ng-app>
            喜欢谁
            <input type="text" ng-model="myname" />
            喜欢{{myname}}
        </body>
    </html>

     初始化值1

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
        </head>
        <body>
            <body ng-app ng-init="myname='proyuan'">
                请输入你的姓名:<input ng-model="myname">
                你的名字是{{myname}}
            </body>
        </body>
    </html>

     两数相加

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
            <script>
                var app=angular.module('MyApp',[])
                app.controller('mycontroller',function($scope){
                    $scope.add=function(){
                        return parseInt($scope.x)+parseInt($scope.y)
                    }
                });
            </script>
        </head>
        <body ng-app='MyApp' ng-controller='mycontroller'>
            <!--ng-controller为程序添加控制器-->
            x:<input ng-model="x" />
            y:<input ng-model="y" />
            结果{{add()}}
        </body>
    </html>
    View Code

    点击事件

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
            <script>
                var app=angular.module('MyApp',[])
                app.controller('mycontroller',function($scope){
                    $scope.add=function(){
                        $scope.z=parseInt($scope.x)+parseInt($scope.y)
                    }
                });
            </script>
        </head>
        <body ng-app='MyApp' ng-controller='mycontroller'>
            <!--ng-controller为程序添加控制器-->
            x:<input ng-model="x" />
            y:<input ng-model="y" />
            <button ng-click="add()">点击</button>
            结果{{z}}
        </body>
    </html>
    View Code

     

     循环数组(注意集合不能重复...)

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            
            <script type="text/javascript" src="js/angular.min.js"></script>
            <script>
                var app = angular.module('myApp',[])
                app.controller('mycontroller',function($scope){
                    $scope.list=[66,87,43,32,08];
                });
            </script>
        </head>
        <body ng-app="myApp" ng-controller="mycontroller">
            <table>
                <tr ng-repeat="x in list">
                    <td>{{x}}</td>
                </tr>
            </table>
        </body>
    </html>
    View Code

     循环数组对象

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <script type="text/javascript" src="js/angular.min.js"></script>
            <script>
                var app=angular.module('MyApp',[])
                app.controller('mycontroller',function($scope){
                    $scope.list=[
                        {name:'sx',address:'保定',tel:1515},
                        {name:'xy',address:'保定',tel:1515},
                        {name:'sy',address:'保定',tel:1515}
                    ]
                });
            </script>
        </head>
        <body ng-app="MyApp" ng-controller="mycontroller">
            <table>
                <tr>
                    <td>姓名</td>
                    <td>地址</td>
                    <td>电话</td>
                </tr>
                <tr ng-repeat="entity in list">
                    <td>{{entity.name}}</td>
                    <td>{{entity.address}}</td>
                    <td>{{entity.tel}}</td>
                </tr>
            </table>
            
        </body>
    </html>
    View Code

  • 相关阅读:
    Hibernate+JPA (EntityMange讲解)
    JPA和Hibernate的区别
    Hibernate与Jpa的关系,终于弄懂
    JEE学习线路
    J2EE中你必须了解的13种技术规范
    js设置datagriad的行移动
    js正则表达式中的特殊字符
    iOS 开发之动画篇
    Phone APP设计规范/iPad APP设计规范/Android APP设计规范/网页设计规范
    打包程序时的证书问题(上传APP就出现Missing iOS Distribution signing indetity for)
  • 原文地址:https://www.cnblogs.com/proyuan/p/11847894.html
Copyright © 2020-2023  润新知