Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use ng-bind instead of {{...}} to prevent extra quoting #764

Closed
musically-ut opened this issue Oct 8, 2013 · 4 comments
Closed

Use ng-bind instead of {{...}} to prevent extra quoting #764

musically-ut opened this issue Oct 8, 2013 · 4 comments

Comments

@musically-ut
Copy link

Since the cellTemplate.html uses {{COL_FIELD CUSTOM_FILTERS}} form, if a non-string object is passed to it, the toJSON function is called and it returns a quoted string. These quotes are hard to get rid of in the cells.

One reason one might need such an object is for aiding in sorting, since the sortFn does not get the complete row context.

This problem as can be seen in the Time Spent column here (plunker). The labels here are double quoted. Here, we want to show the labels but the sort function should depend on the actual number of seconds.

The SortableValue class here implements the toJSON function, which returns the label.

This problem can be fixed easily by switching to an ng-bind, as shown here (plunker).

In this case, the SortableValue class needs to implement toString function.

The change required was relatively minor.

I can make a pull request with this commit if this solution is acceptable. All tests pass with this change.

However, could this be an angular bug?

@roblarsen roblarsen reopened this Oct 9, 2013
@roblarsen
Copy link
Contributor

I'll get the hang of github one of these days.

@musically-ut
Copy link
Author

:-)

Happens to the best as well. Can I help in the "investigation"?

@roblarsen
Copy link
Contributor

I think you've provided a succinct description of the issue. The "investigation" would be whether or not the code change to use ng-bind is better or if simply documenting this case and leaving the code alone is better.

@musically-ut
Copy link
Author

For what it's worth, IMO, leaving the code alone would restrict the the effective use of the sortFn without resorting to monkey-patching string objects in the field to hold the true values on which to sort by.

Perhaps there is another, and more correct, way of passing context to the sortFn that I do not know of?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants