关于angular中指令调用controller的方法:&
来源:互联网 发布:java正则表达式全匹配 编辑:程序博客网 时间:2024/05/16 18:54
html:
<!doctype html><html ng-app="app"> <head> </head> <body> <div ng-controller="MyCtrl"> <greeting aa="sayHello(name)"></greeting><br> <greeting aa="sayHello(name)"></greeting><br> <greeting aa="sayHello(name)"></greeting><br> </div> <script src="angular.min.js"></script> <script src="js/cc.js"></script> </body></html>
js:
var app = angular.module('app', []);app.controller('MyCtrl', function($scope){ $scope.sayHello = function(name) { alert("Hello"+name); }})app.directive("greeting", function(){ return { scope: { greet: '&aa' }, restrict: "AE", template: '<input type="text" ng-model="username"><br><button ng-click="greet({name:username})">click</button>' }});
首先,scope中的@aa匹配html中的aa的内容(是个方法),然后将greet指向sayHello,参数绑定了input的内容username,将name的值指向username,点击按钮调用方法。
0 0
- 关于angular中指令调用controller的方法:&
- angularJs中指令的directive的controller属性
- AngularJS 中指令与controller交互
- 关于angular controller之间的通信
- LLVM中指令的一生
- angularjs中指令的scope
- Struts2调用action中指定的方法
- angular controller的使用
- OR1200中指令Cache的结构
- cpu中指令流水线处理指令的过程
- angularjs中指令的scope作用域
- Nginx配置文件中指令的作用注释
- 关于angular中函数的调用
- Java-调用抽象类中指定参数的构造方法
- angular的父子controller通信
- angular的同级controller通信
- 程序入口自动调用 controller 的方法
- 调用Controller方法的几种方式
- Multi-Task Learning with Low Rank Attribute Embedding for Person Re-identification
- JavaWeb 输出随机验证码图片
- javascript中判断radio是否选中的方法
- 数字图像处理四大函数库优缺点
- 第十周练习 1010 又一版 A+B
- 关于angular中指令调用controller的方法:&
- Vim设置颜色主题(colorscheme)
- UITextFiled时时获取当前输入的字符长度
- SUN SVM 卷管理
- Python——赋值语句
- innodb_read_only 和read_only
- android RadioButton自定义图片样式
- c++ string replace
- springmvc mybatis 整合