0

Being a newbie in AngularJS and JSON, I have the following JSON-code:

{
    key: 'EI',
    value: 'Eingepasst',
    rate: Settings.get('partnerRate'), 
    variants:
    [
        { key: 'E0', value: 'Regulär', multiplier: 1, rate: Settings.get('partnerRate') }
    ]
},

However it should only be "used" in case a specific variable in AngularJS-code (to be detailed $.scope.something) gets a specific value.

How can I add such an if-clause herein (if possible)?

3
  • What do you mean by "it should only be 'used'...". Do you mean you want to prevent it from showing in html? Commented May 17, 2016 at 0:16
  • Yes, that is correct. Commented May 19, 2016 at 15:18
  • Does my reply help to better understand my issue and in case would it be possible to try an answer? Commented May 20, 2016 at 17:18

1 Answer 1

1

You can use ng-if in your html where you are binding your json data.

So let's say you have a div that is bound to some of the properties on your model, you can wrap that all in a div that has ng-if on it as follows:

<div ng-if="something === expectedValue">
    <div>{{obj.rate}}</div>
    <div>{{obj.value}}</div>
</div>

This is a pretty primitive example, but if you have "something" defined on your $scope it should work.

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.