angular js 实例参数学习
2024-08-28 04:36:49
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="[add your bin description]">
<meta charset="utf-8">
<title>JS Bin</title>
<script src="http://apps.bdimg.com/libs/angular.js/1.4.0-beta.4/angular.min.js"></script>
<script>
//directive文件directives.js中定义一个myTest
//定义一个模块 angular.module('myApp',[]), 获取一个模块 angular.module('myApp')
var phonecatDirectives = angular.module('phonecatDirectives', []);
//定义一个指令
phonecatDirectives.directive('myTest', function() {
return {
restrict: 'ACEM',
require: '^ngModel',
scope: {
ngModel: '=' //变量 数据绑定
},
template: '<div><h4>Weather for {{ngModel}}</h4></div>'
}
}); //controller文件controller.js中定义directive1 定义控制器 var dtControllers = angular.module('dtControllers', []); dtControllers.controller('directive1',['$scope',
function($scope) {
$scope.name = 'this is tank test';
}
]); //在app文件app.js中整合controller,directive 模块 var phonecatApp = angular.module('phonecatApp', [
'phonecatDirectives',
'dtControllers'
]); </script>
</head>
<body ng-app="phonecatApp">
<div ng-controller="directive1">
<input type="text" ng-model="city" placeholder="Enter a city" /> <my-test ng-model="city" ></my-test>
<span my-test="exp" ng-model="city"></span>
<!-- directive: my-test exp -->
<span ng-model="city"></span>
</div>
</body>
</html>
最新文章
- java 多线程 4 线程池
- UVA 1395 (kruskal)
- ASP.NET学习笔记1—— MVC
- 理解运算符 || 和 &;&; 及方法
- 《30天自制操作系统》02_day_学习笔记
- show engine innodb status 详解
- 用Python编写九九乘法表考虑print自动换行问题
- 【转】Android手机客户端关于二维码扫描的源码--不错
- 如何判断一个变量是数组Array类型
- Stacked Regression的详细步骤和使用注意事项
- golang异常处理
- spring boot 入门(一)
- Win7系统安装Centos7.0双系统(三)
- 转 Failed to run the WC DB work queue associated with 错误的解决
- 在net中json序列化与反序列化
- 【洛谷】【单调栈】P1901 发射站
- Final发布文案+美工
- angularjs控制器之间的数据共享与通信
- laravel 使用EasyWechat 3分钟完成微信支付(以APP支付为例)
- bzoj 1015 星球大战starwar