Controller中错误 TypeError: $rootScope.$broadcast is not a function
2016-04-14 16:38
513 查看
最近研究Angluar的前端开发,遇到
TypeError: $rootScope.$broadcast is not a function 错误!
代码:
错误原因:
TypeError: $rootScope.$broadcast is not a function 错误!
代码:
... myApp.controller('queryCtrl',['$scope','$document','$rootScope',function($scope,$rootScope){ $scope.queryClick = function(){ var url = "http://localhost:8080/DataVisualor/ServletJson?"+ "TID="+tID+"&"+ "TOwner="+tOwner+"&"+ "TNumber="+carNumber+"&"+ "TStartTime="+tStartTime+"&"+ "TEndTime=" + tEndTime ; $rootScope.$broadcast('update',url); }]);
错误原因:
'$document','$rootScope',function($scope,$rootScope
'$document','$rootScope'顺序需要互换,不然,function中$rootScope对应到$document 类型了,没有 $rootScope.$broadcast方法。
相关文章推荐
- angular.element方法汇总
- 深入学习JavaScript的AngularJS框架中指令的使用方法
- Angular用来控制元素的展示与否的原生指令介绍
- 使用angular写一个hello world
- vue,angular,avalon这三种MVVM框架优缺点
- 使用Angular和Nodejs、socket.io搭建聊天室及多人聊天室
- Android使用广播(BroadCast)实现强制下线的方法
- Android中的广播(BroadCast)详细介绍
- AngularJS页面访问时出现页面闪烁问题的解决
- 利用CSS3在Angular中实现动画
- 初识angular框架后的所思所想
- 实例剖析AngularJS框架中数据的双向绑定运用
- 理解Angular数据双向绑定
- Angular中的Promise对象($q介绍)
- Angular实现form自动布局
- 自定义Angular指令与jQuery实现的Bootstrap风格数据双向绑定的单选与多选下拉框
- angular简介和其特点介绍
- AngularJS使用angular-formly进行表单验证
- 详解JavaScript的AngularJS框架中的作用域与数据绑定
- 给angular加上动画效遇到的问题总结