Well, I'm trying to load a json object to display its information on the screen. The code I'm using is as follows:
(function() {
var app = angular.module('tela', []);
app.controller('TelaController', ['$http', function($http){
var user = this; //testei com $http.get também
$http.jsonp('info.json').success(function(data){
user = data;
});
}]);
var usuario = {
tipo: 'engenheiro',
maquina: 'XX160',
cliente: 'malhas',
status: true
};
})();
HTML
<!doctype html>
<html ng-app="tela">
<head>
<meta charset="UTF-8">
<title>Tela</title>
<link rel="stylesheet" href="css/normalize.css">
<link rel="stylesheet" href="css/layout.css">
<script src="js/angular.min.js"></script>
<script src="app.js"></script>
<link rel="icon" href="favicon.ico" type="image/x-icon">
</head>
<body ng-controller="TelaController as display">
<header> <!-- cabeçalho -->
<table align="center">
<tbody>
<tr>
<td rowspan="3"><img src="imagens/logo.png" alt="Audaces a tecnologia da moda"></td>
<td><b>Acesso: </b> {{display.user.tipo}}</td>
<td rowspan="3"><b>Status:</b><img src="imagens/positivo.png" alt="status" height="15" width="15" ng-show="display.user.status"><img src="imagens/negativo.png" alt="status" height="15" width="15" ng-show="!display.user.status">{{display.user.ativo}}</td>
</tr>
<tr>
<td><b>Maquina:</b> {{display.user.maquina}}</td>
</tr>
<tr>
<td><b>Cliente:</b> {{display.user.cliente}}</td>
</tr>
</tbody>
</table>
</header>
When I did direct this.user = usuario
it worked, however this data I will have to be reading constantly. Do you know how to solve?