markacola / angular-formly-repeating-section

Repeating sections type for Angular Formly.
3 stars 3 forks source link

How to keep track of which repeat in a watcher #1

Open jerowe opened 8 years ago

jerowe commented 8 years ago

Hello,

Thanks for wrapping this up! I was having a tough time getting the repeating section to work just from the docs, installed this, and it just worked. ;-)

This is more of a question and/or cry for help rather than an issue.

Say I have a repeating section, and I implement a watcher as shown here. When I'm in the watcher how do I know which element of the repeating section I'm on?

Thanks again!

markacola commented 8 years ago

Hey, no problems :smile:, glad it helped you out.

As for keeping track of which section you are on, with the current setup I think the only way would be to parse the individual field ids. If you have a look here, you'll see how the ids are created.

This could probably do with a bit of a refactor if you wanted to have a go? Might be able to make it somewhat compreshensible :stuck_out_tongue_closed_eyes:.

jerowe commented 8 years ago

My javascript is very rudimentary, but I'm trying to improve it. I'll try to look into this by the end of the week.

Thanks again. ;-)

jerowe commented 8 years ago

Just asking, what is this syntax?

export default ngModule => {
markacola commented 8 years ago

So there are a few things going on there, if you aren't familiar with ES6 syntax then it might be a bit confronting, but basically this file exports a function that accepts the ngModule variable as its argument. You can read up on the es6 module system here and shorthand arrow function here. This file is imported here, and the function is executed at line 6.

markacola commented 8 years ago

If you wanted a more indepth explaination of the module system and arrow functions have a look here and here

jerowe commented 8 years ago

Thanks! This is very helpful!

On Tue, Oct 11, 2016 at 2:12 PM Mark Cola notifications@github.com wrote:

If you wanted a more indepth explaination of the module system and arrow functions have a look here http://exploringjs.com/es6/ch_modules.html and here http://exploringjs.com/es6/ch_arrow-functions.html

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/markacola/angular-formly-repeating-section/issues/1#issuecomment-252869163, or mute the thread https://github.com/notifications/unsubscribe-auth/AFTFRk2hKRoDdFFLe989jbE2xXOj309nks5qy2EngaJpZM4KMa62 .