• AngularJS中的控制器示例_2


    <!doctype html>
    <html ng-app="myApp">
    	<head>
    		<script src="C:\Users\yuli\Desktop\bower_components\angularjs\angular.js"></script>
    		<script type="text/javascript">
    			angular.module('myApp', []).controller('MyController', function ($scope, $timeout) {
    				var updateClock = function() {
    					$scope.clock = new Date();
    					$timeout(function() {
    						updateClock();
    					}, 1000);
    				};
    				updateClock();
    
    				$scope.a_click = function (msg){
    					console.log(msg);
    				}
    				$scope.value = 1;
    				$scope.add = function (n){
    					$scope.value += n;
    				}
    
    				$scope.clear = function(){
    					$scope.value = 0;
    				}
    			});
    		</script>
    	</head>
    	<body>
    		<div ng-controller="MyController">
    			<h1>Hello {{ clock }}!</h1>
    			这是AngularJS的测试程序。
    			<a href="" ng-click="a_click('hello')">click me console.log message.</a>
    			<a href="" ng-click="add(2)">add 2.</a>
    			<input type="text" ng-model="value"/>
    
    			<br />
    			<a href="" ng-click="clear()">clear.</a>
    		</div>
    	</body>
    </html
    

      

  • 相关阅读:
    HDU
    Groundhog Build Home
    The Moving Points
    Problem I. Count
    Problem E. TeaTree
    树的启发式合并
    Special Segments of Permutation
    网络流24题
    2015-2016 Northwestern European Regional Contest (NWERC 2015)
    The 2018 ACM-ICPC Asia Beijing Regional Contest
  • 原文地址:https://www.cnblogs.com/chengshuiqiang/p/4548071.html
Copyright © 2020-2023  润新知