Home >Web Front-end >HTML Tutorial >angularjs-display HTML elements

angularjs-display HTML elements

高洛峰
高洛峰Original
2017-02-13 15:18:081488browse

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<title></title>
	<link rel="stylesheet" href="">
</head>
<body>
	<div ng-app="myApp" ng-controller="personCtrl">
		<button ng-click="toggle()">显示/隐藏</button>
		<p ng-show="myVar">
			名:<input type="text" ng-model="firstName"><br/>
			姓:<input type="text" ng-model="lastName"><br/>
			<br>
			Full Name:{{firstName + " " + lastName}}
		</p>
	</div>
</body>
<script src="http://cdn.static.runoob.com/libs/angular.js/1.4.6/angular.min.js"></script>
<script>
	var app = angular.module(&#39;myApp&#39;,[]);
	app.controller(&#39;personCtrl&#39;,function($scope){
		$scope.firstName = "John";
		$scope.lastName = "Doe";
		$scope.myVar = true;
		$scope.toggle = function(){
			$scope.myVar = !$scope.myVar;
		}
	});
</script>
</html>

For more angularjs-display HTML elements related articles, please pay attention to the PHP Chinese website!

Statement:
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