1

I have a simple html that loads JSON data into a table using Angularjs ng-repeat. One of the fields come as 1 or zero. I want to write a simple AngularJs directive that will show check-boxes as either checked(1) or not (0); and show text success against (1) and failure against(0) rows.

2
  • 1
    What have you tried? What is your question exactly? Without using a custom directive you could simply use the built in directive ng-checked Commented Dec 9, 2013 at 19:19
  • Maybe this FIDDLE I put together will help you. It's not exactly what you're doing but I think it will help get you there. Commented Dec 9, 2013 at 19:24

1 Answer 1

0

I'm starting with angular, you can use ng-model inside your ng-repeat and ng-if to display to decode value inside the loop.

Code:

<div ng-controller="Ctrl">
    <div ng-repeat="o in obj">{{o.id}}
        <input type="checkbox" ng-model="o.checked">
        <div ng-if="o.checked == true">success</div>
        <div ng-if="o.checked != true">fail!</div>
    </div>
</div>

Demo: http://jsfiddle.net/IrvinDominin/G9m4H/

Sign up to request clarification or add additional context in comments.

Comments

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.