【问题标题】:how to concatinate a string to a $scope model in angularjs?如何将字符串连接到 angularjs 中的 $scope 模型?
【发布时间】:2015-11-28 03:44:22
【问题描述】:

如何将变量连接到$scope 模型。我正在尝试做这样的事情

for(var i=0;i<=response.length-1;i++)
{
   $scope.formData.jobId+i=response[i].jobId;
} 

如何将变量i 连接到$scope.formData.jobId 使其变为$scope.formData.jobId1$scope.formData.jobId2 等等。

【问题讨论】:

    标签: javascript angularjs scope angularjs-scope angularjs-forms


    【解决方案1】:

    您可以通过动态构造属性名称并将其用作字符串来访问它

    $scope.formData['jobId' + i] = response[i].jobId;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 2020-08-16
      • 1970-01-01
      • 1970-01-01
      • 2011-08-09
      • 1970-01-01
      相关资源
      最近更新 更多