Angular学习(3)- 双向梆定

示例代码:

<!DOCTYPE html>
<html ng-app="MyApp">
<head>
    <title>Study 3</title>
    <script type="text/javascript" src="js/angular.js"></script>
</head>
<body>
    <div ng-controller="testController">
        <h1>{{title}}</h1>
        Name:<input type="text" ng-model="name" />
        Fraction:<input type="text" ng-model="fraction" />
        <hr />
        <h1>{{previewTitle}}</h1>
        <b>{{name}}</b>:({{fraction}})
    </div>
    <script type="text/javascript">
        var app = angular.module("MyApp", [], function() { });
        var testController = function($scope) {
            $scope.title = "Robin";
            $scope.previewTitle = "Test";
            $scope.name = "";
            $scope.fraction = "";
        }
    </script>
</body>
</html>

 

posted @ 2014-03-28 15:09  横渡  阅读(423)  评论(0编辑  收藏  举报