<!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>

最新文章

  1. java 多线程 4 线程池
  2. UVA 1395 (kruskal)
  3. ASP.NET学习笔记1—— MVC
  4. 理解运算符 || 和 &amp;&amp; 及方法
  5. 《30天自制操作系统》02_day_学习笔记
  6. show engine innodb status 详解
  7. 用Python编写九九乘法表考虑print自动换行问题
  8. 【转】Android手机客户端关于二维码扫描的源码--不错
  9. 如何判断一个变量是数组Array类型
  10. Stacked Regression的详细步骤和使用注意事项
  11. golang异常处理
  12. spring boot 入门(一)
  13. Win7系统安装Centos7.0双系统(三)
  14. 转 Failed to run the WC DB work queue associated with 错误的解决
  15. 在net中json序列化与反序列化
  16. 【洛谷】【单调栈】P1901 发射站
  17. Final发布文案+美工
  18. angularjs控制器之间的数据共享与通信
  19. laravel 使用EasyWechat 3分钟完成微信支付(以APP支付为例)
  20. bzoj 1015 星球大战starwar

热门文章

  1. html——a标签添加点击事件,火狐浏览器直接显示0
  2. Emmet快速编写CSS样式
  3. MySQL 5.7原生JSON格式支持
  4. HDU 1227 Fast Food (DP)
  5. 用django-tinymce搞个富文本编辑器
  6. lintcode 中等题:unique Binary Search Tree 不同的二叉查找树
  7. jdbc的通讯录CRUD
  8. css元素z-index设置为什么不起作用?
  9. 249. Group Shifted Strings
  10. 用Telnet发送HTTP请求