1

Filters, I want to select first one radio button.

Restorent1 ✔ | restorent 2 | restorent3 | restorent4

<div ng-repeat="restorent_type in restaurant_types" style="margin:5px;" class="col col-offset-10">
    <label class="item item-radio radio-label {{restorent_type.RESCOD}}">
        <input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.RESCOD}}" ng-click="filters.RESCOD = restorent_type.RESCOD">
        <div class="item-content">
            {{restorent_type.RESCOD}}
        </div>
        <i class="radio-icon ion-checkmark"></i>
    </label>
</div>
1
  • and if i want to generate click event of it then it is possible? Commented Jun 20, 2015 at 7:19

4 Answers 4

3

Use ng-checked

If we put an Angular interpolation expression into such an attribute then the binding information would be lost when the browser removes the attribute. The ngChecked directive solves this problem for the checked attribute. This complementary directive is not removed by the browser and so provides a permanent reliable place to store the binding information.

<input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.RESCOD}}" ng-checked="$index === 1 ? true : false" ng-click="filters.RESCOD = restorent_type.RESCOD">

Or Use

ng-checked="$first"
Sign up to request clarification or add additional context in comments.

Comments

2

you can use $first also

<div ng-repeat="restorent_type in restaurant_types" style="margin:5px;" class="col col-offset-10">
    <label class="item item-radio radio-label {{restorent_type.RESCOD}}">
        <input type="radio" name="group" ng-model="restorent.types" value="{{restorent_type.RESCOD}}" ng-click="filters.RESCOD = restorent_type.RESCOD" ng-checked="$first">       
        <div class="item-content">
            {{restorent_type.RESCOD}}
        </div>
        <i class="radio-icon ion-checkmark"></i>
    </label>
</div>

4 Comments

and if i want to generate click event of it then it is possible?
yes you can ng-click for that.. and if you will give some more specific info then probably i could help
then how can i trigger click event of first element?
ng-checked="checkFirst($first)" IN controller $scope.checkFirst=function(first){if(first == true){ //your function }}
1

It's easy, you can do this in your controller:

restaurant_types[0].types = true;

check first restaurant_types[0].types to true

1 Comment

Hello, I am newer in angular js. So i try your solution to bind in my code but i can't work. I have added ng-checked="restaurant_types.types" to checkbox but it can't work!!
0

Good Quation Try This Code

angular.module "myApp", []

angular.module("myApp").controller "myCtrl", ($scope) ->

  $scope.keywords = [{name: "kw1", checked: false}, {name: "kw2", checked: true}]

1 Comment

Welcome to Stack Overflow! While this code snippet may be the solution, including an explanation really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.