Skip to content

Instantly share code, notes, and snippets.

@leandroh
Created February 18, 2016 18:30
Show Gist options
  • Select an option

  • Save leandroh/bfaf526b84da2abf8409 to your computer and use it in GitHub Desktop.

Select an option

Save leandroh/bfaf526b84da2abf8409 to your computer and use it in GitHub Desktop.
Exemplo simples de uma pequena diretiva em AngularJS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Bem vindo ao mundo das diretivas no AngularJS!</title>
</head>
<body ng-app="app">
<minha-diretiva></minha-diretiva>
<script src="https://code.angularjs.org/1.5.0/angular.min.js"></script>
<script>
(function() {
'use strict';
angular.module('app', []); // Cria nosso módulo principal
// Cria uma diretiva tendo como parametros uma string e uma function
angular.module('app')
.directive('minhaDiretiva', function() {
return {
template: '<div>Bem vindo ao mundo das diretivas!</div>' // Opção de template
}
});
})();
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment