标签:
层级关系如下
<ons-page ng-controller="tabbarIndexController"> <ons-tabbar position="top" var="tabbar"> <ons-tab label="新建消息" page="pages/newMsg.html" active="true"></ons-tab> <ons-tab label="历史消息管理" page="pages/historyMsg.html"></ons-tab> </ons-tabbar> </ons-page>
现在需将historyMsgController中的数据传给newMsgController
思路1:在historyMsgController中用$scope.$emit将数据发送给父级的tabbarIndexController,父级用$on接受数据后再用$scope.$broadcast广播给子级的newMsgController,子级用$on接受。
思路2:在historyMsgController中用$scope.$parent.$emit直接利用父级scope来$scope.$broadcast广播给子级的newMsgController,子级用$on接受。
思路2明显简单了许多。
标签:
原文地址:http://www.cnblogs.com/li-you/p/5888055.html