javascript-databinding

Proper dependecy tracking in a custom binding

ⅰ亾dé卋堺 提交于 2020-01-25 08:24:05
问题 What I'm trying to achieve is to visually filter table rows generated by the foreach binding in a way that tr elements of the rows that are filtered out would be hidden instead of removed from the DOM. This approach significantly improves rendering performance when a user changes filter conditions. This is why I don't want the foreach to be bound to a computed observable array which is updated depending on the filter condition. I want this solution to be a ready-to-use building block that I

When to use or not use parentheses with observables in data-binding expressions

允我心安 提交于 2019-12-09 19:06:28
问题 I have seen other threads on this but I'm still confused and I think I am presenting a different case here. I'm using the revealing pattern to return a view model object to my HTML document. Thus, I have a view model object that looks something like this: var vm = function() { var customProperty = ko.numbericObservable(0); return { customProperty: customProperty }; } (); From this, you can see that customProperty is being assigned to a Knockout numeric observable with an initial value of 0.

When to use or not use parentheses with observables in data-binding expressions

…衆ロ難τιáo~ 提交于 2019-12-04 15:51:31
I have seen other threads on this but I'm still confused and I think I am presenting a different case here. I'm using the revealing pattern to return a view model object to my HTML document. Thus, I have a view model object that looks something like this: var vm = function() { var customProperty = ko.numbericObservable(0); return { customProperty: customProperty }; } (); From this, you can see that customProperty is being assigned to a Knockout numeric observable with an initial value of 0. In the HTML document that includes the JavaScript above, I have a SPAN element with a data-bind

Can you use array.filter in an Angular binding?

岁酱吖の 提交于 2019-12-02 00:02:43
问题 I have this line in my template: <span>{{ data.things.find(r => { return r.id == 5 }).description }}</span> When I run this, I get the following error: Parser Error: Bindings cannot contain assignments at column... Does this mean you can't use array.find from within a binding? I know my objects have values, and the expression evaluates in the watch window. Any suggestions? Edit: While this question and its answer will get around the issue, I don't think they are duplicates. That question is

Can you use array.filter in an Angular binding?

ⅰ亾dé卋堺 提交于 2019-12-01 20:47:08
I have this line in my template: <span>{{ data.things.find(r => { return r.id == 5 }).description }}</span> When I run this, I get the following error: Parser Error: Bindings cannot contain assignments at column... Does this mean you can't use array.find from within a binding? I know my objects have values, and the expression evaluates in the watch window. Any suggestions? Edit: While this question and its answer will get around the issue, I don't think they are duplicates. That question is specific to filtering to a smaller list, perhaps one record, where as my problem is getting one record