-
Notifications
You must be signed in to change notification settings - Fork 90
Fix #571 - pfTableView: ng-include inside ng-repeat hurts performance #572
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
Fix #571 - pfTableView: ng-include inside ng-repeat hurts performance #572
Conversation
| * <ul style='list-style-type: none'> | ||
| * <li>.header - (string) Text label for a column header | ||
| * <li>.itemField - (string) Item field to associate with a particular column. | ||
| * <li>.templateFn - (function) (optional) Template function used to render each cell of the column. Example: <pre>templateFn: value => `<span class="text-danger">${value}</span>`</pre> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some info. on the pros and cons of using templateFn as opposed to htmlTemplate. Pro: Is more performant than htmlTemplate. Con: Doesn't support AngularJS directives in the template, therefore it doesn't support things like ng-click.
| * <li>.header - (string) Text label for a column header | ||
| * <li>.itemField - (string) Item field to associate with a particular column. | ||
| * <li>.templateFn - (function) (optional) Template function used to render each cell of the column. Example: <pre>templateFn: value => `<span class="text-danger">${value}</span>`</pre> | ||
| * <li>.htmlTemplate - (string) (optional) id/name of an embedded ng/html template. Ex: htmlTemplate="name_template.html". The template will be used to render each cell of the column. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above. Please include some info as to why an app dev might choose htmlTemplate over templateFn, or visa-versa. -thanks
dtaylor113
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Nice solution!
dtaylor113
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add an example of how one sets up and uses templateFn? Probably just adding the example you used in the unit tests to the ngDoc desc would be enough. -Thanks
|
Thanks @akieling , LGTM 👍 |
dtaylor113
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @akieling, we have started using automatic semantic version releasing, so you will need to change your commit messages to a specific format, ex: "fix(pfTableView): ng-include inside ng-repeat hurts performance"
Add new configuration property to
columnsobject to define a template functionThe goal of this PR is to provide a fix to performance issues caused by the use of ng-include inside ng-repeat to parse and include the content of each table cell that has a template.
This change is backward compatible and doesn't affect existing code that depends on the
htmlTemplateproperty of thecolumnsobject. This change adds a new property calledtempateFnas a potential replacement tohtmlTemplate.List of changes:
templateFnproperty to documentation$sceinto controller to tell AngularJS to trust the template HTMLhasHTMLTemplateandgetHTMLTemplatefunctions from controller because we can check whether the columns have a template by just checking the existence of thehtmlTemplateandtemplateFnpropertiesng-bind-htmlto invoke the template function and inject the results in the cellsPR Checklist