Angular.js 使用、MVC

AngularJs框架
	MVW设计模式,model view whatever,支持模块化和双向数据绑定,为克服html语言在构建App上天生的不足

使用前奏:
	1、引入文件
	2、在html标签中添加<html ng-app>

使用:
	在要输入的标签中添加ng-model='变量名';表示在该标签中输入的内容全都放进变量中,变量放在其他标签中实现同步效果
	实现了MVC模式

在这里插入图片描述
代码示例:

<html ng-app>
<head>
	<meta charset="utf-8">
	<meta name='viewport' content='width=device-width,user-scalable=no,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0'>
	<title></title>
	<script src='js/underscore.js'></script>
	<!-- 引入百度地图 -->
	<script src='js/angular.js'></script>
	<style>

	</style>
</head>
<body>
	<input type="text" ng-model='msg' placeholder='请输入内容'>
	<h1>输入的内容是:{{msg}}</h1>

	<script>


	</script>
	
</body>

</html>
发布了281 篇原创文章 · 获赞 3 · 访问量 4476

猜你喜欢

转载自blog.csdn.net/weixin_43294560/article/details/104025233