0
Guys, I’m trying to load a json object to display your 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 was doing straight this.user = usuario
it worked, but these data I will have to read constantly. They know how to solve?
Please explain the context better. Where the display variable is declared, what would it be? ;
user
in the part where you describe would be the sameuser
that is inside the controller ?– Felippe Tadeu
@Felippetadeu
display
is an alias of the controller:ng-controller="TelaController as display"
– bfavaretto
What would be the constant ? A setInterval for example ?
– Felippe Tadeu