5、的,所以可以利用作用域链传递事件。传递事件有2种方式:*$broadcast:触发的事件要通知整个事件系统(允许任意作用域处理这个事件)就要向下传播。*$emit:如果要提醒一个全局模块,需要通知更高层次的作用域时(例如$rootscope)需要把事件向上传递。作用域上使用$on进行事件监听。示例JavaScriptapp.controller(JParentController,,function($scope){$scopc.$on(5$fromSubControllcrClickJ,function(c,data){c
6、onsole,log(data);//hello});});app.controller(JChildController,,function($scope){$scopc.sayHello=function(){$scope.$emit('$fromSubControllerClick,,'hello');};});//HTML 7、Sayhello
8、nctionMyControl1er($scope,$rootScope){varunbind二$rootScopc.$on(,somcComporient.somcCrazyEvcnt,,function(){console.logCfoo,);});$scope.$on(‘Sdestr
此文档下载收益归作者所有