How to pass a lambda expression to an AngularJS directive -


I am trying to create a set of AngularJS instructions that will process an array of objects and use specific objects For example, if the array contains strings, for example, such an instruction could present a comma-separated list of those strings. I hope to use such an instruction like this:

  & lt; Csv-list item = "myArray" /> However, as mentioned above, as I mentioned above, I want the array of implementing objects to be flexible enough to cross the command, so that the instructions are the property of a particular property or sub-example if I can give the lambda expression to the instruction , Then I would imagine using it like this:  
  & lt; Csv-list item = "myArray" member = "element = & gt; element.name" / & gt;  

I think there is a suggested angular letter pattern to solve such problems, but I am quite new to Angular JS, so I have not found it yet.

There are several ways to do this, using the $ parse service is the easiest Maybe

  var parser = $ parse ("name"); Var element = {name: "thingA"}; Var x = parse (element); Console.log (x); // "Cheese A"  

Pars is optimized to work quickly in these scenarios (single property look-up). You can put the same "parser" function around and apply it to each element.

You can also split up on ". And simply look at yourself in simple form (reading your member in the form of a 'member'), in simple form:

  var path = myPath.split ('.' ); Var val = myObj; (Var i = 0; i & lt; paths.length; i ++) for {val = val [path [i]]; } Return valve;  

There are also many linq-like libraries that support the Lambda expressions as strings (linqjs, fromjs). If you have a fat arrow function.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -