0

This is my json object response:

{
"draftType": "manualinput",
"senderdata": "123456789",
"senderName": "ifelse",
"message": "Hi",
"draftName": "Testing"
}

I am displaying this in UI using ng-repeat:

controllers.js:

$http({
   method: 'GET',
   url: '/api/getdraft'

}).then(function (response) {
   $scope.drafts = response.data;
}, function (response) {
   console.log(response);
});

my code:

tr(ng-repeat='draft in drafts')
 td {{draft.draftName}}
 td {{draft.senderName}}
 td {{draft.message}}

But i need some condition, if my draftType object key have string called "manualinput" i want to display datas,

sometimes draftType will come as "contactinput",

so i dont want to display if my draftType is not equal to "manualinput".

Is this possible to do?

2
  • 2
    Use ng-if="draft.draftType.includes('manualinput')" inside ng-repeat. Commented Jan 9, 2018 at 5:29
  • Its working thanks it should be in answer :) Commented Jan 9, 2018 at 5:32

2 Answers 2

2

You need to use ng-if with ng-repeat

CODE:

tr(ng-repeat='draft in drafts' ng-if="draft.draftType === 'manualinput'")
Sign up to request clarification or add additional context in comments.

2 Comments

post full answer! it will helpful to me, this should be in comment section :)
i am typing from phone, it takes some time :P
2

You can add ng-if with ng-repeat. please try with this.

tr(ng-repeat='draft in drafts') data-ng-if="draft.draftType === 'manualinput'"
 td {{draft.draftName}}
 td {{draft.senderName}}
 td {{draft.message}}

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.