Dealing with a JSON file:
$scope.favoriteThings = [
{nr: 1, text: "Raindrops on roses"},
{nr: 2, text: "Whiskers on kittens"},
{nr: 3, text: "Bright copper kettles"},
{nr: 4, text: "Warm woolen mittens"},
{nr: 5, text: "Brown paper packages tied up with strings"},
{nr: 6, text: "Cream colored ponies"},
{nr: 7, text: "Crisp apple streudels"},
{nr: 8, text: "Doorbells"},
{nr: 9, text: "Sleigh bells"},
{nr: 10, text: "Schnitzel with noodles"},
{nr: 11, text: "Wild geese that fly with the moon on their wings"},
{nr: 12, text: "Girls in white dresses with blue satin sashes"},
{nr: 13, text: "Snowflakes that stay on my nose and eyelashes"},
{nr: 14, text: "Silver white winters that melt into springs"}
];
- Utilizing the ng-repeat directive to iterate through the array above.
<li ng-repeat="thing in favoriteThings">
<input type="radio" value="{{thing}}" ng-model="$parent.selected" name="stuff"/>
{{thing.text}}
</li>
- Displaying the selected checkbox's value as
Selected thing: {{selected}}{{selected.nr}}
- This leads to the following output:
Selected thing: {"nr":5,"text":"Brown paper packages tied up with strings"}
When trying to access the "nr" attribute using {{selected.nr}}
, it does not work
Any suggestions as to why?
PLUNKER LINK
EDIT: Also aiming to access the TEXT attribute