Angular 遍历循环数组

var app = angular.module('Mywind',['ui.router'])

app.controller('Myautumn',function($scope,$http,$filter){

  var objs =[{a:1},{a:2}];
  angular.forEach(objs, function(data,index,array){
  //data等价于array[index]
    console.log(data.a+'='+array[index].a);
  // console.log(data.a);
  //转化为小写
    console.log(angular.lowercase("A"))
  //转化为大写
    console.log(angular.uppercase("b"))

  });

//$http
$scope.SWLogin = function() {
  $http({
    method: 'POST',
    url: url + '',
    params: {}
  }).then(function successCallback(response) {
    $scope.val = response.data
//map 循环遍历
    var role = {
    "1":'文字a',
    "6":'文字b',
    "9":'文字c',
    "7":'文字d',
    "3":'文字e',
    "5":'文字f'
  }
//循环遍历改变值
  $scope.val = $scope.val.map(item => {
    var obj = {};
//取值x.realShow
    obj.realShow = role[item.prizeid] ? role[item.prizeid] : '';
    return Object.assign({}, item, obj);
  })
  }, function errorCallback(response) {
    $scope.message = message;
    console.log("error:" + response + "");
  });
}

});

转载于:https://www.cnblogs.com/wr1994/p/8337847.html

你可能感兴趣的:(Angular 遍历循环数组)