Home > Web Front-end > JS Tutorial > AngularJS ng-if directive

AngularJS ng-if directive

黄舟
Release: 2017-02-18 13:14:16
Original
1450 people have browsed it

1. Problem background

AngularJS uses the ng-if directive to determine whether the object element is empty


2. Implementation source code

<!DOCTYPE html>
<html ng-app="ifApp">
	<head>
		<meta charset="UTF-8">
		<title>AngularJS之ng-if指令</title>
		<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
		<script>
			var app = angular.module("ifApp",[]);
			app.controller("ifController",function($scope){
				$scope.person = {
					name:{
						username:"张三",
						sex:"男",
						age:"23"
					},
					scores:{
						item:"语文",score:"123"
					}
				};
			});
		</script>
	</head>
	<body ng-controller="ifController">
		<p ng-if="person != null">
			<p ng-repeat="p in person">
				<p ng-if="person.name != null">
					<label>{{p.username}}</label>
				</p>
			</p>
		</p>
	</body>
</html>
Copy after login


3. Implementation result

    AngularJS ng-if directive

The above is the content of the ng-if directive of AngularJS. For more related content, please pay attention to the PHP Chinese website (www .php.cn)!


Related labels:
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
Latest Issues
angular.js - angularJS ng-style用法
From 1970-01-01 08:00:00
0
0
0
angular.js - AngularJS form validation
From 1970-01-01 08:00:00
0
0
0
angular.js - Learning AngularJS
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template