AngularJs 父子级Controller传递数据
<div ng-controller="MyAccountCtrl"> <div ng-controller="TransferCtrl">
............. </div> </div>
// 子级传递数据给父级
// 子级传递
$scope.checkLoggedIn = function(type) {
$scope.transferType = type;
$scope.$emit('transfer.type', type);
} // 父级接收
$scope.$on('transfer.type', function(event, data) {
$scope.transferType = data;
});
$scope.checkLoggedIn = function() {
var type = $scope.transferType;
}
// 父级传递数据给子级
// 父级传递
$scope.transferType = '';
$scope.checkLoggedIn = function(type) {
$scope.transferType = type;
$scope.$broadcast('transfer.type', type);
} // 子级接收
$scope.transferType = '';
$scope.$on('transfer.type', function(event, data) {
$scope.transferType = data;
});
$scope.checkLoggedIn = function() {
var type = $scope.transferType;
}
在线实例:http://each.sinaapp.com/angular/apps/app-broadcast.html
AngularJs 父子级Controller传递数据的更多相关文章
- Vue.js 父子组件相互传递数据
父传子 : 子组件接收变量名=父组件传递的数据 如::f-cmsg="fmsg" 注意驼峰问题 子传父:@子组件关联的方法名 = 父组件接受的方法名 如:@func=" ...
- ASP.NET MVC 学习2、从Controller传递数据到View
参考:http://www.asp.net/mvc/tutorials/mvc-4/getting-started-with-aspnet-mvc4/adding-a-view 一,Control ...
- vue组件-构成组件-父子组件相互传递数据
组件对于vue来说非常重要,学习学习了基础vue后,再回过头来把组件弄透! 一.概念 组件意味着协同工作,通常父子组件会是这样的关系:组件 A 在它的模版中使用了组件 B . 它们之间必然需要相互通信 ...
- angularJs 中ui-router 路由向controller传递数据
页面上 : ui-sref="home.dataAnalysis({role:'thirdpart:tokenverify',menuType:'a'})" 路由设置 .state ...
- vue 父子组件相互传递数据
例子一 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta ...
- Linux 利用管道父子进程间传递数据
[原文] fork()函数:用于创建子进程,子进程完全复制父进程的资源,相当于父进程的拷贝.具体理解,运用父进程的同一套代码,通过判断进程ID来执行不同进程的不同任务. 返回值正常为子进程ID,出错返 ...
- vue组件父子组件之间传递数据
举个栗子: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...
- C# 把带有父子关系的数据转化为------树形结构的数据 ,以及 找出父子级关系的数据中里面的根数据Id
紧接上一篇,将List<Menu>的扁平结构数据, 转换成树形结构的数据 返回给前端 , 废话不多说,开撸! --------------------- 步骤: 1. 建 Menu ...
- 通过$broadcast或$emit在子级和父级controller之间进行值传递
通过$broadcast或$emit在controller之间进行值传递,不过这些controller必须是子级或者父级关系, $emit只能向父级parent controller传递事件event ...
随机推荐
- kingso_sort - Taocode
kingso_sort - Taocode 如何编写新sort 由于排序逻辑多种多样,kingso的排序设计成是由一个个排序对象串起的排序链条组成.排序对象之间可以任意组合(只需要改配置文件),就可以 ...
- 08-IOSCore - App Store、国际化/本地化
App Store 1. 帐号身份 0. 有Xcode 写程序,在虚拟机上运行 1. 成为苹果使用者 appleid 验证邮箱 权限: 能下载应用程序 2. 成为苹果开发者 https://devel ...
- Python 绝对简明手册
Python 绝对简明手册 help(函数名)来获取相关信息 另外,自带的文档和google也是不可少的 2. 基本语法2.1. if / elif / else x=int(raw_input(&q ...
- SqlServer和Oracle中一些常用的sql语句6 存储过程
--不带参数的存储过程 CREATE procedure proc_sql1 as begin declare @i int set @i=0 while @i<26 begin print c ...
- 分享一个嵌入式httpdserver开发库 - boahttpd library
http://sourceforge.net/projects/boahttpd/ 一个C接口的开发库,适用于 windows/linux/或其它嵌入式平台,支持CGI扩展,支持多线程.採用面向对象开 ...
- UVA 10815 Andy's First Dictionary(字符处理)
Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy task for him ...
- QQ登录-第三方SDK的接入总结
由于项目的需要,使用了[QQ登录]SDK 的相关功能! 1.集成[QQ登录]SDK [QQ登录]SDK下载地址: http://wiki.open.qq.com/wiki/website/SD ...
- RAC 11.2.0.4 安装 遇到 INS-06001
今天安装11.2.0.4的grid软件,在配置passwordless SSH的时候,点击setup 出现此错误 开始网上搜了一把.说什么的都有,什么系统bug啊什么的 但是我另外一套rac却很正常就 ...
- LoadRunner 监控 Apache
配置Apache部分 1.修改Apache中Httpd.conf文件 <Location /server-status> SetHandler server-status Order de ...
- LA 3942 Remember the Word(前缀树&树上DP)
3942 - Remember the Word Neal is very curious about combinatorial problems, and now here comes a pro ...