5
I wonder how I can access the contents of the variable scope
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>
<body ng-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 the code: http://jsfiddle.net/v0pLv0ny/
Thanks for the description on the difference between this and $Cope !
– Douglas dos Santos
+1 for describing the correct reason. =)
– OnoSendai