示例代码:
<!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>