Image or folder selection event inside App


#1

hi, I am developing android app where I need to populate some images like

<div>
<img src="1.jpg">1</img>
<img src="1.jpg">1</img>
</div>

What I need is, I need to show user a check-box when user taps on an image. (Basic image gallery functionality.).

Can some one explain me how can i acheive this?


#2

this is invalid html…
<img src="1.jpg"> thats it.

you can fill an image array in your controller -> in your template you can use ng-repeat to display the images and add an checkbox foreach image.

This checkboxes have to associated with a model for the data-binding. (ng-model) This could be another object, filled in your controller, something like that:

$scope.imageCheckboxes = {
      0: false, // value for image 1
      1: false, // value for image 2
      .....
};
$scope.images = [
      '1.jpeg', // index = 0
      '2.jpeg'  // index = 1
]

The model for an image would be imageCheckboxes[$index] in your ng-repeat.
So now you have to set the value of the key true or false if the checkbox of the associated image is checked/unchecked.
https://docs.angularjs.org/api/ng/input/input[checkbox]


#3

Thanks I understood what you are saying . I will give a shot.


#4

Checkout these samples by @mhartington



#5

@Calendee
Wuuuaaaahhhh, please let users try on their own with some hints.
If it fails you can post links to complete solutions anyway…
But the users should try and fail to learn or to have to do something on their own (even if it is only a codepen with buggy ugly code).

Thanks!


#6

@bengtler We’re here to help users. Sometimes that means showing them something they can learn from. Sometimes that means nudging them in the right direction and expecting them to walk on their own.

Please leave it up to individual contributors to decide how they want to be a part of the community. This forum is successful because everyone helps how and when they can.


#7

@Calendee Hey, no probs. I try to measure something like knowledges in how the user describes his problem and so on. On that i decide how “much” my help will be in the first case.

But you are right everyone should help like he wants.

annd to not spam the forum:

@mrvamsidhar
do you achieve progress?


#8

Thanks Guys. Yes. I am able to get it work.


#9

Always appreciate your prompt responses and willingness to help.

Great work @Calendee.

FP