Reputation: 57
So I have this code :https://jsfiddle.net/afelipeor/o2qqt7ux/ and I need to be able to access the values in the object, and display the text in the html, as it is for a multi-language website. However, I can't seem to be able to, and all my research showed is that I'm declaring everything correctly.
As long as the value I need is not in a object, it works, so I know that I'm not doing things completely wrong. For example, if I create $scope.text = 'text';
and access it with {{ text }}
, it works as it should.
However, I must be doing something wrong. Does anyone know what?
Upvotes: 0
Views: 119
Reputation: 1486
From your fiddle, your data is nested in an array.
$scope.english = [
{
home: "home",
about: "About Template",
services: "Services",
contact: "Contact",
eng:"English",
ptg: "Portuguese"
}
];
You can get it to display properly like this:
<ul class="nav navbar-nav navbar-right">
<li><a href="#">{{english[0].home}}</a></li>
<li><a href="#">{{english[0].about}}</a></li>
<li><a href="#">{{english[0].services}}</a></li>
<li>
<select id="navLang">
<option >{{english[0].eng}}</option>
<option>{{english[0].ptg}}</option>
</select>
</li>
</ul>
Upvotes: 1