scope内部函数定义
1 //定位 2 $scope.LocateByPoint = function (x,y) { 3 if(!x || !y) 4 { 5 window.alert("GPS坐标不存在,无法定位") 6 return; 7 } 8 // 发送广播,将参数传递过去 9 var assetLocal = {10 xValue:x,11 yValue:y12 };13 // 向首页地图发送广播14 $rootScope.$broadcast('LocalAssetData', assetLocal);15 //跳转16 $rootScope.tabManager.addTab($scope.menu);17 };
scope外面调用
//通过scope对应的controller所在的元素id(“flashContent”),找到scope,再调用内部函数2var scopeCur = angular.element(flashContent).scope();3scopeCur.$apply(function(){4 scopeCur.LocateByPoint(info.Lon ,info.Lat);5});