angular.js的ng-app 指令定义一个 AngularJS 应用程序。

<!DOCTYPE html>
<html lang="en" ng-app>
<head>
    <meta charset="UTF-8">
    <title>局部数据</title>
    <script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/angular.min.js"></script>
    <script src="js/6.js"></script>
    <style>
        @charset"utf-8";

    </style>
</head>
<body>
    <div class="container" ng-controller="shuju">
    <div class="row">
            <div class="col-md-12 lin-height">ng-app 指令定义一个 AngularJS 应用程序。</div>
        </div>
        <div class="row">
            <div class="col-md-6 bind lin-height">ng-model 指令把元素值(比如输入域的值)绑定到应用程序</div>
            <div class="col-md-6 "><input type="text" class="form-control" ng-model="yonghu"></div>
        </div>
        <div class="row">
            <div class="col-md-4 bind lin-height">用户名</div>
            <div class="col-md-8 bind">
                <input type="text" class="form-control" ng-model="yonghu">
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 bind lin-height">一个子scope通常原型继承于它的父scope。应用于这个规则的表达式是一个使用scope:{...}的指令</div>
        </div>
        <div class="row">
            <div class="col-md-4 bind lin-height">ng-model="chuanshu.names"</div>
            <div class="col-md-8 bind">
                <input type="text" class="form-control" ng-model="chuanshu.names">
            </div>
        </div>
        <div class="row">
            <div class="col-md-4 bind lin-height">ng-model="chuanshu.dan"</div>
            <div class="col-md-8 bind">
                <input type="text" class="form-control" ng-model="chuanshu.dan">
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 bind lin-height">通过函数计算表达式计算绑定的数据之间的关系</div>
        </div>
        <div class="row">
            <div class="col-md-4 bind lin-height">$scope.sum=function(){}</div>
            <div class="col-md-8 lin-height" style="color:red;font-size:28px">
                {{sum()}}
            </div>
        </div>

        <div class="row">
            <div class="col-md-12 lin-height">
                循环跨域去取数据渲染页面
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 lin-height">
                ng-init和ng-bind配合使用,封装数据和及时解析书籍
            </div>
        </div>
        <div class="row">
            <div class="col-md-12" ng-init="danjia=10;shu=20">
                <p ng-bind="danjia * shu"></p>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12" ng-init="array=[1,2,3,4,5]">
                <p ng-bind="array[2]"></p>
            </div>
        </div>
        <div class="row">
            <div class="col-md-12 bind lin-height">循环打印出来的数据</div>
        </div>
        <div class="row">
            <ol ng-controller="text">
                <li ng-repeat="guojia in guojias">   {{$index+1}}----
                    {{guojia.cname}}----
                    {{guojia.renkou}}
                </li>
            </ol>
        </div>
        <div class="row">
            <div class="col-md-12 bind lin-height">很牛逼的数据绑定,不经过函数</div>
        </div>
        <div class="row" ng-init="qw=1;dw=3">
            <div class="col-md-6"><input type="text" class="form-control" ng-model="qw"></div>
            <div class="col-md-6"><input type="text" class="form-control" ng-model="dw"></div>
        </div>
        <div class="row">
            <div class="col-md-6">{{ qw * dw }}</div>
        </div>
        <div class="row">
            <div class="col-md-12 bind lin-height">$http 是一个用于读取web服务器上数据的服务。$http.get(url) 是用于读取服务器数据的函数</div>
        </div>
        <div class="row" ng-app="myApp">
            <ol ng-controller="customersCtrl">
                <li ng-repeat="x in names">
                {{ x.Name + ', ' + x.Country }}
                </li>
            </ol>
        </div>
        <div class="row">
            <div class="col-md-6">
                <a href="" name="myname"></a>
            </div>
            <div class="col-md-6">
                <a href="" name="myname"></a>
            </div>
        </div>
    </div>
</body>
</html>

上面的css部分就没有什么东西可说了!直接js了

    function shuju($scope,$timeout){
        $scope.chuanshu={
            names:38,
            dan:0
        };
        $scope.sum=function(){
            return $scope.chuanshu.names*$scope.chuanshu.dan;
        }
    };

        var text = function($scope){
                //alert(1);
                $scope.renkou = 7000;
                $scope.guojias =
                        [
                                {cname:'中国',renkou:1.1},
                                {cname:'日本',renkou:2.2},
                                {cname:'美国',renkou:3.3}
                        ];
                };

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

app.controller('customersCtrl', function($scope, $http) {

  $http.get("http://localhost/de6.js").success(function (response) {$scope.names = response.records;});
});
上一篇:「NOI2015」寿司晚宴 解题报告


下一篇:「SDOI2014」向量集 解题报告