Declare multiple values in ng-init

angularjs, javascript

Solution

Use a function, way more readable:

ng-init="init()"

And:

$scope.init = function() {
    $scope.a = 1;
    $scope.b = 2;
}

Or, if you must, separate inline variables with a semi-colon:

ng-init="a = 1; b = 2"

Problem

So I'm wondering how I can declare multiple values within a single ng-init, without having to create some weird hash, that then I need to always access specifically. so basically I would like ``` <div ng-init="a = 1, b = 2">{{a}}</div> ``` and I'm saying that I would like to avoid having to do ``` <div ng-init="unecessary_bs = {a: 1, b: 2}">{{unecessary_bs.a}}</div> ``` However the reasonable : ``` <div ng-init="a = 1, b = 2">{{a}}</div> ``` doesn't seem to work. Anticipated Thanks

Original source