I added everything inside $scope.model instead of putting everything directly on $scope as this is best practice, believe me it will save you from some headaches, when you have to deal with some directives redefining the current scope.
-----------------
Please remember to click "Mark as Answer" the responsES that resolved your issue.
Thank you JBetencourt. This gives me an idea. My issue is with these lines:
<div ng-if="model.selectedBlock">
<div ng-repeat="row in model.selectedBlock.rows" ng-click="model.selectedRow=row">
For me on page load, I need to bind everything and not just the selectedBlock so it is like this:
<div ng-repeat="row in model.blocks.rows" ng-click="model.selectedRow=row">
I am not sure how selectedRow could locate the right row since ng-repeat doesn't just happen in selectedBlock only. ng-repeat happens to all rows in all blocks.
my solution was assuming the 2 repeats where separated: show list of blocks, select one, then show the list of rows for that block in a separated repeat, select one, then display the textarea to edit the label.
JBetancourt, thanks for your reply again. I ran into one issue. Is there a way I can create a variable row without going through ng click. I actually selected the row in another way and selectedRow is not undefined. All I need is to some how assign the
model.selectedRow = row.
<div ng-repeat="row in model.selectedBlock.rows" ???="model.selectedRow=row">
</div>
Member
429 Points
1829 Posts
Is there a way I could shorten this in angular js
Jun 22, 2017 02:20 AM|asplearning|LINK
Hello everyone I have this line of code:
Blocks and rows are arrays. A block contains many rows. I am just trying to see if there is a way I can assign
to something like selectedRow.label for readability.
Thanks.
Participant
1380 Points
608 Posts
Re: Is there a way I could shorten this in angular js
Jun 22, 2017 03:23 AM|JBetancourt|LINK
on the block selection fill the selectedBlock property
on the row selection fill the selectedRow property
then your text area can be binded to selectedRow.label
I added everything inside $scope.model instead of putting everything directly on $scope as this is best practice, believe me it will save you from some headaches, when you have to deal with some directives redefining the current scope.
Please remember to click "Mark as Answer" the responsES that resolved your issue.
Member
429 Points
1829 Posts
Re: Is there a way I could shorten this in angular js
Jun 22, 2017 03:56 AM|asplearning|LINK
Thank you JBetencourt. This gives me an idea. My issue is with these lines:
For me on page load, I need to bind everything and not just the selectedBlock so it is like this:
I am not sure how selectedRow could locate the right row since ng-repeat doesn't just happen in selectedBlock only. ng-repeat happens to all rows in all blocks.
Thanks.
Participant
1380 Points
608 Posts
Re: Is there a way I could shorten this in angular js
Jun 22, 2017 01:17 PM|JBetancourt|LINK
my solution was assuming the 2 repeats where separated: show list of blocks, select one, then show the list of rows for that block in a separated repeat, select one, then display the textarea to edit the label.
If you want nested repeats then you have the option to show also nested inputs or have only one input outside.
Lets assume you have nested repeats and the input outside:
if you want nested textareas you can do:
Please remember to click "Mark as Answer" the responsES that resolved your issue.
Member
429 Points
1829 Posts
Re: Is there a way I could shorten this in angular js
Jun 27, 2017 02:59 AM|asplearning|LINK
JBetancourt, thanks for your reply again. I ran into one issue. Is there a way I can create a variable row without going through ng click. I actually selected the row in another way and selectedRow is not undefined. All I need is to some how assign the model.selectedRow = row.
Thanks.
Member
429 Points
1829 Posts
Re: Is there a way I could shorten this in angular js
Jun 28, 2017 04:31 AM|asplearning|LINK
I just realized I could do this in angular js in html markup page itself
Hope it helps others too