我有想发出作为参数的函数。发射一个函数作为参数
我曾尝试以下:
$scope.$watchGroup(['watch1', 'watch2'], function(newValues, oldValues, scope) {
if (scope.1 && scope.2) {
$scope.$emit('enableButton', {$scope.submit(true)});
}
});
其中$ scope.submit(真)是我在电流控制器中定义的函数。
然后在我的另一个控制器:
$scope.$on('enableButton', function(event, data) {
$scope.buttonAction = data;
});
当我尝试分配$ scope.buttonAction这是通过作为参数传递的函数,该函数在$ EMIT刚刚发生自动闪光。为什么会发生?
您是否没有收到意外的令牌错误? '{$ scope.submit(true)}'是无效的对象语法。 – doldt
做'如果(scope.1 && scope.2)'是有史以来可能..?变量名称不应以数字 –