我有想發出作爲參數的函數。發射一個函數作爲參數
我曾嘗試以下:
$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)'是有史以來可能..?變量名稱不應以數字 –