michaelbromley / michaelbromley/angularUtils
dirPagination: Syntax error is thrown when the value of paganation-id starts with a digit
Open
@michaelbromley is already working on this.
Since Sep 22, 2016.
enhancement
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 842
- PR merge metrics
- No merged PRs in 30d
Description
I am using angular-utils-pagination#^0.11.1
the issue is pretty easy to solve by adding
Steps to reproduce:
pass dirPaganation paganation-id="1" it will throw syntax error on compile
the source of the issue is that $parse will throw if the a string passed to is not a valid variable name such as the string '1122aasd'
, adding an '_' int the beginning fixes it
function makeCurrentPageGetterFn(scope, attrs, paginationId) {
var currentPageGetter;
if (attrs.currentPage) {
currentPageGetter = $parse(attrs.currentPage);
} else {
// If the current-page attribute was not set, we'll make our own.
// Replace any non-alphanumeric characters which might confuse
// the $parse service and give unexpected results.
// See https://github.com/michaelbromley/angularUtils/issues/233
var defaultCurrentPage = '_' +(paginationId + '__currentPage').replace(/\W/g, '_'); <-- this line
scope[defaultCurrentPage] = 1;
currentPageGetter = $parse(defaultCurrentPage);
}
return currentPageGetter;
}
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.