0

I have static page with articles and I would like to fill number of likes for each article from json with angularjs. Is that posible or do I need to load whole page as template and fill all the detail with ng-repeat?

Is there something like

$("#like id" + i).val(jsonarray[i]) 

for angularjs?

0

1 Answer 1

1

Assign the array to the scope and use the interpolation {{ }} and ng-repeat in the HTML

JS Controller:

$scope.jsonarray = jsonarray;

HTML:

<div ng-repeat="value in jsonarray">{{value}}</div>

Or:

<div id="like">{{jsonarray[0]}}</div>
Sign up to request clarification or add additional context in comments.

2 Comments

But if I have fixed html with different divs that need value from json. This will only repeat this one div.
@stefansixx1 You don't have to use ng-repeat, you can use {{ }} braces at any point to display expressions or scope variables.

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.