Home > Web Front-end > JS Tutorial > body text

AngularJS $window window object

黄舟
Release: 2017-02-18 13:50:34
Original
1275 people have browsed it

1. Problem background

Print the contents of the input box through the $window object


2. Implementation source code

<!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>
Copy after login


3. Implementation result


The above is the content of the $window window object in AngularJS. For more related content, please pay attention to the PHP Chinese website (www .php.cn)!


source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!