网站地图    收藏   

主页 > 前端 > AngularJS >

angularJS 入门基础_AngularJS_自学php网

来源:自学PHP网    时间:2016-04-21 15:40 作者: 阅读:

[导读] 这篇文章主要介绍了angularJS 入门基础的相关资料,需要的朋友可以参考下...

angular   

所有用到的库, 全部用的CDN:

复制代码 代码如下:
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>
    <script src="http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type="text/javascript"></script>

.angular的数据绑定实例,这个是最基础的,angular的所有枝叶全部从这里开始:.

复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>
    <script src="http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type="text/javascript"></script>
</head>
<body ng-app="app">
    <script type="text/javascript">
           var app = angular.module("app",[]);
    </script>
    <div class="panel panel-default">
        <div class="panel-heading">
            angular最强大的东西,数据的绑定binding
        </div>
        <div class="panel-body">
            <div id="bind" ng-controller="bf">
                <input type="text" ng-model="data" />
                {{data}}
                <script>
                    app.controller("bf", function($scope) {
                        $scope.data = "testData";
                        //$scope.$apply();
                    });
                </script>
            </div>
        </div>
    </div>
</body>
</html>

通过angular,展示数组对应的数据;.

复制代码 代码如下:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>angular</title>
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <script src="http://cdn.bootcss.com/jquery/2.1.1/jquery.js"></script>
    <script src="http://cdn.bootcss.com/angular.js/1.3.0-beta.13/angular.min.js"></script>
    <link href="http://cdn.bootcss.com/bootstrap/3.3.1/css/bootstrap.css" rel="stylesheet">
    <script src="http://cdn.bootcss.com/underscore.js/1.7.0/underscore-min.js" type="text/javascript"></script>
</head>
<body ng-app="app">
    <script type="text/javascript">
           var app = angular.module("app",[]);
    </script>
    <div class="panel panel-default">
        <div class="panel-heading">
            通过angular,展示数组对应的数据;
        </div>
        <div class="panel-body">
            <div id="arr-bind" ng-app="arr-app" ng-controller="arrCon">
                <style>
                    .s{
                        color:#f00;
                    }
                    li{
                        cursor: pointer;
                    }
                </style>
                <ul>
                    <li ng-repeat="i in lists" ng-click="bered($index)" ng-class="{s : $index == flag}">
                        {{i.name}}----{{i.age}}
                    </li>
      &

自学PHP网专注网站建设学习,PHP程序学习,平面设计学习,以及操作系统学习

京ICP备14009008号-1@版权所有www.zixuephp.com

网站声明:本站所有视频,教程都由网友上传,站长收集和分享给大家学习使用,如由牵扯版权问题请联系站长邮箱904561283@qq.com

添加评论