Skip to content

Instantly share code, notes, and snippets.

@iamblue
Created April 10, 2014 10:19
Show Gist options
  • Select an option

  • Save iamblue/10365244 to your computer and use it in GitHub Desktop.

Select an option

Save iamblue/10365244 to your computer and use it in GitHub Desktop.
$scope.step1pdata = ->
newdata = []
angular.forEach $scope.pdata, (v,i,o) !->
__tmp =
n : i + 1
id : v.id
productId : v.productId
userId : v.userId
newdata.push __tmp
newdata
@tomchentw

Copy link
Copy Markdown
newdata = for v, i in $scope.pdata
  v{id, productId, userId} <<< {
    n: i+1
  }

@iamblue

iamblue commented Apr 10, 2014

Copy link
Copy Markdown
Author

幹! 強!

@poying

poying commented Apr 11, 2014

Copy link
Copy Markdown
newdata = $scope.pdata.map((v, i) => {
  v.n += 1;
  return v;
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment