jquery - Knockout Js - ko.utils.arrayFirst does not work -


I have the following knockout code

I try to return the food each line
This function takes ID of current available mileys - and should return some object

  self. Function (item) {return item.id == id;}); }; & Lt; Span data-bound = "text: $ root.getMealById (meal.id)" />   

For some reason he did not do this, why?

array first will return an object and you will place an object in the input field Trying to bind the text value, which will not work.

If your function is a string value, it will work fine, updated bella here:

New function To get the name of the food as the value, note the .emailName; at the end of the array

  self.getMealNameById = function (id) {var meal = ko.utils.arrayFirst (self .availableMeals (), function (item) {Return item.id == ID;}). Nickname; Meal of return; };   

In addition to this, the data-dam has been updated to input to use the new function: data- Bind = "Value: GetMealNameById (1)"

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -