![](/img/trans.png)
[英]Angular JS how to update scope variable inside another scope variable
[英]To get the $scope.x1 variable using the another variable in angular js
有一個變量名數組
$scope.intialArray =[];
$scope.intialArray[0] ='x1';
$scope.intialArray[1] ='x2';
這些值在控制器中計算
$scope.x1 = 'somevalue';
$scope.x2 ='another value';
現在,我想使用intailArray通過以下代碼以編程方式獲取varialbe名稱。
$scope.($$scope.intialArray[0].val);
您能幫我在angularjs中使用變量評估嗎
$scope[$scope.intialArray[0]];
嘗試這種方式:)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.