Maison  >  Article  >  interface Web  >  AngularJS之$window窗口对象

AngularJS之$window窗口对象

黄舟
黄舟original
2017-02-18 13:50:341217parcourir

1、问题背景

     通过$window对象打印出输入框的内容


2、实现源码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>AngularJS之$window窗口对象</title>
		<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
		<script>
			var app = angular.module("winApp",[]);
			app.controller("winCon",function($window,$scope){
				$scope.phone = "15969569556";
				$scope.showPhone = function(){
					$window.alert("您输入的手机号是:"+$scope.phone);
				};
			});
		</script>
	</head>
	<body ng-app="winApp">
		<p ng-controller="winCon">
			<input type="text" id="phone" maxlength="11" ng-model="phone"/>
			<button ng-click="showPhone();">显示手机号</button>
		</p>
	</body>
</html>


3、实现结果


 以上就是AngularJS之$window窗口对象的内容,更多相关内容请关注PHP中文网(www.php.cn)!


Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn