connorbode / angular-repeat-n Goto Github PK
View Code? Open in Web Editor NEWAngular directive used to repeat a DOM element n times.
Angular directive used to repeat a DOM element n times.
I'm using your directive for an app but because of how you used scope, I'm not able to use the index on the element with the directive.
i.e you would expect to see 50 lines, but you end up with 100 because of the scoping.
<div ng-repeat-n="100" ng-show="$index < 50">
This index will print {{$index}}
</div>
example:
http://jsfiddle.net/qejrsw4n/6/
Its really problematic if your dealing with tables, where you can't just insert spans or divs where ever you want, and where you may want to adjust colspans based on the index. I'm not likely to create a pull request with my results because I broke your code up into easier to read functions.
https://gist.github.com/mbostwick/48f197d0761a7a17bc3e4fdc9221f2a4
It would be nice if something like ng-repeat-start-n
/ ng-repeat-start-n
would be available in future releases, in addition to AngularJS's native ng-repeat-start-n
/ ng-repeat-start-n
.
Thank you.
Can't access the parent scope from within the ngRepeatN
scope. Probably because it's an isolateScope...
Files in the ./dist folder are 10 months old so when I install a package using bower I get old version.
Could you please rebuild it and commit the new files?
thanks!
I was getting this for awhile and tracked it down to angular-repeat-n...
In my template I do something like this...
ng-repeat-n="(whatever.accountTotalRowCount-whatever.accountRows.length)"
Where both numbers could be 0.
In the for loop at line 38 this can make the i -1 which can't be removed, so it throws:
TypeError: Cannot read property 'remove' of undefined
at Object.fn (angular-repeat-n.js:40)
at n.$digest (angular.js:14308)
at n.$apply (angular.js:14571)
at l (angular.js:9698)
at M (angular.js:9888)
at XMLHttpRequest.F.onload (angular.js:9829)(anonymous function) @ angular.js:11655(anonymous function) @ angular.js:8596n.$digest @ angular.js:14326n.$apply @ angular.js:14571l @ angular.js:9698M @ angular.js:9888F.onload @ angular.js:9829
My hacky fix is to just add this in the first line of the for loop:
if (i===-1) return;
So why the heck would I ever want to do ng-repeat-n="0" ?
I'm basically doing a table which lazy loads data in from a RESTful service. There's a requirement for the empty rows to be available... because requirements!
So I do something hacky like this:
<tr ng-repeat="row in accountRows">
<td>{{ row.id }}</td>
<td>{{ row.name }}</td>
<td>{{ row.whatever }}</td>
</tr>
<tr ng-repeat-n="(accountTotalRowCount-accountRows.length)">
<td colspan="3"> </td>
</tr>
So if there are 0 remaining this will cause that error message.
Would be nice to get the version updated in package.json to match the version - currently it says 0.0.1 instead of 0.1.5. Then it would be nice to have this published in the NPM package registry so we can install with npm install angular-repeat-n
.
Current workaround:
$ npm install --save https://github.com/connorbode/angular-repeat-n#v0.1.5
i"m receiving TypeError: t.removeAttribute is not a function
error from this code:
<div class="entry__row" ng-repeat-n="entryRows" ng-attr-data-index={{$index}}>
...
</div>
I'll get no error if I change $index with some other variable.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.