angularjs - loading array values in custom order using ng-repeat -


Loading the array initial value / first value at the end of the array; Using the Ng-repeat and orderby filters;

In your script.js file, create a sort function.

  $ scope.sort = function (value) {var index = $ scope.myvar.indexOf (value); If (index === 0) {return $ scope.myvar.length; } Return Index; }   

In your index.html file, change your NG-double attribute to look like this:

  & lt; li ng-repeat = "v in myVar | orderBy: type: false" & gt; {{V}} & lt; / li & gt;   

Some things to note, it assumes that you want the natural order of the array, except that you want the first element to go to the end. If you want a different order, then you have to change the sorting function. See for more details.

In addition, in an index of the organs, the indexOf function is not supported in all browsers (IE if I am not mistaken. If it does not already exist, you will need to create it yourself See for help.

Click to see a working leaking version.

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -