AngularJS ng-repeat: Change Array

555 Views Asked by At

I want to change categoryAlpha into a different value (say, into categoryBeta) in the following HTML + AngularJS:

<div ng-repeat="x in categoryAlpha | limitTo:quantity">
  <previews></previews>
  <hr />
</div>

Since ng-repeat isn't a normal attribute, I don't think I can change it through jQuery attr(). Is my only solution regex, or is there an Angular/jQuery method that can change the value categoryAlpha?

Thanks in advance.

1

There are 1 best solutions below

1
On BEST ANSWER

You can for example create function which will return a collection for ng-repeat and assign it to scope. Something like:

// in your controller
$scope.getCategory = function getCategory() {
  return someCondition ? categoryAlpha : categoryBeta;
};

and then in your markup:

<div ng-repeat="x in getCategory() | limitTo:quantity">
  <previews></previews>
  <hr />
</div>