在AngularJs范围内推送数据的正确方法

时间:2014-09-13 05:19:08

标签: angularjs angularjs-scope

这是我的范围格式

    $scope.order.Transaction{
    'source': value,
    'fees': value,
    'ref':value
   }

如何将上述数据推送到现有的$ scope,有人可以指导我朝正确的方向发展吗?这是$ scope.order.Transaction已经包含的内容:     对象{来源:"价值",费用:" 33",参考:" 37226"} 我想把一个新对象推到它。怎么做?

2 个答案:

答案 0 :(得分:1)

它是一个javascript的东西,而不是一个角色

$scope.order.Transaction.source = 'someValue'
$scope.order.Transaction.fees = 'someValue'
$scope.order.Transaction.ref = 'someValue'

答案 1 :(得分:1)

$scope.order.Transactions = [];

$scope.order.Transaction = {
    'source': value,
    'fees': value,
    'ref':value
};

$scope.order.Transactions.push($scope.order.Transaction);