最近在研究google的angularjs

 最近在研究google的angularjs,先做个简单的例子来试试。

 
<!doctype html>
<html lang="en" ng-app="myApp">
<head>
    <meta charset="utf-8">
    <title>parent demo</title>
    <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript" src="scripts/libs/angular.min.js"></script>
</head>
<body>

<div ng-controller="TextController"><p ng-bind="someText.message"></p></div>

<div class="selected"><div><p class="ag">Hello Again</p></div></div>

<form ng-controller="SomeController">
    <input type="checkbox" ng-model="youCheckedIt" />
    <input type="button" ng-click="checkedIt()" value="Click" />
</form>
<script>
    var myAppModule=angular.module('myApp', []);
    myAppModule.controller('TextController', function($scope){
       var someText = {};
        someText.message = 'You have started your journey.';
        $scope.someText = someText;
    });

    myAppModule.controller('SomeController', function($scope){
        $scope.youCheckedIt=true;
        $scope.checkedIt = function(){
            alert($scope.youCheckedIt);
            $scope.youCheckedIt=false;
        };
    });
</script>

<script>
    console.log($( "p.ag" ).parents("div").length);
    $( "p.ag" ).parents("div").css( "background", "yellow" );
</script>


</body>
</html>

原文地址:https://www.cnblogs.com/adam/p/3460124.html