mardi 6 octobre 2015

how to get the object from ng-repeat checkbox values in Angular JS

I'm encountering a problem and I will appreciate someone can help.

Right now I'm showing several checkboxes in my form which are grabbing from my firebase database. And in my controller I'm trying to use ng-submit to store whole data of form. My checkbox JSON format should look like this.

{
    "apple" : true,
    "spotify" : true 
}

The checkbox image here

okay the following is my code from HTML and Javascript

<label class="checkbox-inline" ng-repeat="hashtag in hashtags" for="{{hashtag}}">
  <input type="checkbox" name="{{hashtag.$value}}" id="{{hashtag.$value}}" value="{{hashtag.$value}}" ng-model="hashtag.SELECTED" ng-true-value="true" ng-false-value="false"> 
    {{hashtag.$value | capitalize}}
</label>

My Javascript here

form.$add({
    description: $scope.inputDescription,
    hashtags: {
        *I don't know how to put checkbox's result here.*
    },
    time: Firebase.ServerValue.TIMESTAMP,
    title: $scope.inputTitle,
    url: $scope.inputUrl
})

Anyone can help, please? Thank you so much.




Aucun commentaire:

Enregistrer un commentaire