【发布时间】:2014-07-02 00:39:25
【问题描述】:
我想将数据从一个控制器发送到另一个控制器。其实我已经关注了这个link
我的第一个Controller是这样的:
class ProductCtrl
constructor: ($scope, @$log, @$location, @$timeout, @ProductService) ->
$scope.go = (path) =>
$scope.$emit('handleEmit', @getAllProducts())
$location.path path
第二个:
class UpdateProductCtrl
constructor: ($scope, @$log, @$routeParams) ->
$scope.$on('handleBroadcast', (event, data) ->
console.log(data)
)
App.coffee:
app = angular.module('myApp', dependencies)
app.run ($rootScope, editableOptions) ->
$rootScope.$on 'handleEmit', (event, args) ->
$rootScope.$broadcast 'handleBroadcast', args
当我在 ProductCtrl 中调用 $scope.$emit('handleEmit', @getAllProducts()) 时,App 内咖啡 $rootScope.$on 'handleEmit' 没有触发。请帮助我做错了什么。
【问题讨论】:
标签: angularjs controller coffeescript