Jaime Neves
Front-End Engineer
@dejaneves
FRONT-END DEVELOPER
FRONT-END ENGINEER
JSON
Solicita
index.html
<!DOCTYPE html>
<html lang="pt-BR" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Hello Angular</title>
</head>
<body>
<p>Começando com Angular.JS</p>
</body>
<script src="libs/angular.min.js"> </script>
</html>
<script src="https://code.angularjs.org/1.2.6/angular.js"></script>
var myApp = angular.module("myApp", []);
myApp.controller("HelloCtrl", function($scope) {
$scope.name = "Jaime Neves";
});
<!DOCTYPE html>
<html lang="pt-BR" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Hello Angular</title>
</head>
<body>
<div ng-controller="HelloCtrl">
<p>{{name}}</p>
</div>
</body>
<script src="https://code.angularjs.org/1.2.6/angular.js"></script>
</html>
<!DOCTYPE html>
<html lang="pt-BR" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Hello Angular</title>
</head>
<body>
<div ng-controller="HelloCtrl">
<p>{{name}}</p>
</div>
</body>
<script src="https://code.angularjs.org/1.2.6/angular.js"></script>
</html>
<!doctype html>
<html ng-app="myApp">
<head>
<script>
var myApp = angular.module('myApp', ['ui.router']);
// For Component users, it should look like this:
// var myApp = angular.module('myApp', [require('angular-ui-router')]);
</script>
<script src="https://code.angularjs.org/1.2.6/angular.js"></script>
<script src="js/angular-ui-router.min.js"></script>
</head>
<body>
...
</body>
</html>
myApp.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('state1', {
url: "/state1",
templateUrl: "partials/state1.html"
})
.state('state2.list', {
url: "/list",
templateUrl: "partials/state2.list.html",
controller: 'controllers'
});
});
Jquery
$.post( "ajax/test.php", function( data ) {
// seu código aqui
});
AngularJS
var app = angular.module('myApp', ['ngResource', 'ngRoute']);
app.factory('Notes', ['$resource', function($resource) {
return $resource('/notes/:id', null,
{ 'update': { method:'PUT' }
});
}]);
app.controller('NotesCtrl', ['$scope', '$routeParams', 'Notes',
function($scope, $routeParams, Notes) {
var note = Notes.get({ id:$routeParams.id });
$id = note.id;
Notes.update({ id:$id }, note);
}]);
Separar Controllers em Pastas
Usar um controller para cada view
<!DOCTYPE html>
<html lang="pt-BR" ng-app="myApp">
<head>
<meta charset="utf-8">
<title>Hello Angular</title>
</head>
<body>
<div ng-controller="HelloCtrl">
<p>{{name}}</p>
</div>
</body>
</html>
Minificar CSS, Javacript e HTML
Criar apenas um js principal
npm install -g grunt-cli
Gerenciador de Pacotes
npm install -g bower
Fonte: InfoQ
Discovery APIs for Oracle, MySQL, PostgreSQL and SQL Server
category.js
module.exports = function(Category){
};
category.json
( para ajudar a diagnosticar falhas de memória )
A Interface
var urlToChangeStream = '/api/MyModels/change-stream?_format=event-stream';
var src = new EventSource(urlToChangeStream);
src.addEventListener('data', function(msg) {
var data = JSON.parse(msg.data);
console.log(data); // the change object
});
A interface EventSource é usada para receber eventos enviados pelo servidor (server-sent events). Ele se conecta via HTTP em um servidor e recebe eventos com o formato text/event-stream sem fechar a conexão.