Peter Peter - 1 year ago 122
AngularJS Question

Angular curly braces not working, basic code

<script type="text/javascript" src="">
<body style="padding: 20px 20pc;">
<div ng-app="app">
<div ng-repeat="item in 'somewords'.split('')">
{{$index + 1}}. {{item}}
<script type="text/javascript">

Hi everyone, I've tried to look up for some old post already but found nothing that could really help me.
I'm learning Angular and in a Tutorial they use this code that is supposed to count and split the letters in the word given.
The problem I'm having is that I get the curly braces as if they where some text in HTML. What am I doing wrong?

Answer Source

You have problems with the duplicates. You should use track by to solve the issue.

<div ng-repeat="item in 'somewords'.split('') track by $index">
        {{$index + 1}}. {{item}}

Here is a codepen. Also here is some documentation.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download