AngularJS
AngularJS
<!DOCTYPE HTML>
<html>
<head>
<title> 测试页 </title>
<meta charset="utf-8">
</head>
<body>
<div ng-app="" ng-controller="DuController">
name:
<input type="text" ng-model="username"><hr>
<button ng-click="sayHi()">我要打招呼</button><!--注意sayHi方法的要括号的。-->
<hr>
{{greeting}}
</div>
</body>
</html>
<script>
function DuController($scope){
$scope.username='du';
$scope.sayHi=function(){
$scope.greeting='hello '+$scope.username+'!';
};
};
</script>


浙公网安备 33010602011771号