user727728
user727728

Reputation: 743

Correct way to push data in AngularJs scope

This is the scope format I have

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

How do I push the above data to existing $scope,can anyone please guide me in the right direction? This is what $scope.order.Transaction already contains: Object {source: "value", fees: "33", ref: "37226"} I want to push a new object to it.How to do it?

Upvotes: 0

Views: 82

Answers (2)

Nhan Nguyen
Nhan Nguyen

Reputation: 495

$scope.order.Transactions = [];

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

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

Upvotes: 1

Narek Mamikonyan
Narek Mamikonyan

Reputation: 4611

Its an javascript thing not an angular

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

Upvotes: 1

Related Questions