I would like to know how I can access the contents of the scope
variable in AngularJS?
Theoretically I did everything "correct", ie declaring the variable in controller and assigning values in it:
var app = angular.module('vagalume', []);
app.controller('BandsController', function($scope) {
$scope.teste = 'VALOR DE TESTE';
this.lista = [
{
nome: 'U2',
estilo: 'Rock'
},
{
nome: 'Guns And Roses',
estilo: 'Rock'
},
{
nome: 'Scorpions',
estilo: 'Rock'
}
];
});
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.1/angular.min.js"></script><bodyng-app="vagalume">
<div class="artistas" ng-controller="BandsController as bandas">
{{'TESTE:' + bandas.teste}}
<ul>
<li ng-repeat="banda in bandas.lista">{{banda.nome}}</li>
</ul>
</div>
</body>
The test never returns anything ...
Link to code: link