I'm developing a rails app with angular, and in the past, I had been using $scope to access variables and methods of the angular's controllers. After watching the Shaping up with Angular.js course at codeschool, I realized that the usage of this and the alias of controllers are a better way of accessing them.
Anyway, my app works fine with $scope but when I change to the "this" implementation, the laboratories var came empty...
I let some code here: html:
<div ng-controller="LaboratorioController as labCtrl">
<tr ng-repeat="laboratorio in labCtrl.laboratorios" >
<td>{{ laboratorio.nombre }}</td>
<td>{{ laboratorio.razon_social }}</td>
<td>{{ laboratorio.direccion }}</td>
angular code:
(function() {
var app = angular.module('guiaV', []);
app.controller('LaboratorioController', function( $http) {
this.laboratorios = [];
return $http.get('./laboratorios.json').success(function(data) {
return this.laboratorios = data;
});
});
})();
any idea?