AngularJS之ng-controller指令

1、问题背景

     ng-controller:该指令是用于AngularJS应用添加控制器

 

2、实现源码

<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>AngularJS之ng-controller指令</title>
		<script src="http://apps.bdimg.com/libs/angular.js/1.4.6/angular.min.js"></script>
		<script>
			var app = angular.module("youApp",[]);
			app.controller("haiCon",function($scope){
				$scope.studentNo = "2016010101";
				$scope.studentName = "张华";
			});
		</script>
	</head>
	<body>
		<div ng-app="youApp" ng-controller="haiCon">
			<input type="text" ng-model="studentNo" /><br><br>
			<input type="text" ng-model="studentName" /><br><br>
			学号:{{studentNo}}<br>
			姓名:{{studentName}}
		</div>
	</body>
</html>

3、实现结果


再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

猜你喜欢

转载自www.cnblogs.com/odejsjhshw/p/10382891.html
今日推荐