假设我有这个函数,它将值赋给$作用域。变量
function Tasker($http,$scope,angularServiceMessageVariable)
{
angularServiceMessageVariable = "some data";
}
我用这个
来命名它 function RunLockExpirationNotificationService($scope, $http, $spinner, $actions) {
$scope.runService = function () {
Tasker($http,$scope,$scope.LockExpirationNotificationServiceMessage);
};
}
我得到未定义的angularservicemessagvariable这基本上是$范围。我要传递给方法的变量。有人能告诉我我在这里做错了什么吗?我需要在另一个函数中设置作用域变量的值。我尝试了$parse,但这给了我未定义的异常。
谢谢
传递要添加到作用域的变量的名称。改变:
function Tasker($http,$scope,angularServiceMessageVariable)
{
$scope[angularServiceMessageVariable] = "some data";
}
和
function RunLockExpirationNotificationService($scope, $http, $spinner, $actions) {
$scope.runService = function () {
Tasker($http,$scope,'LockExpirationNotificationServiceMessage');
};
}