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>

 

 

posted @ 2015-07-18 22:30  公子若不胖天下谁胖  阅读(326)  评论(0)    收藏  举报