Skip to content

Instantly share code, notes, and snippets.

@gabrielfeitosa
Last active October 11, 2016 02:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabrielfeitosa/d35552ec986aee14c3c67cb2d6408b83 to your computer and use it in GitHub Desktop.
Save gabrielfeitosa/d35552ec986aee14c3c67cb2d6408b83 to your computer and use it in GitHub Desktop.
Padronização dos componentes com AngularJS
(function () {
angular.module('app', [])
.directive('botao', function () {
return {
restrict: 'E',
replace: true,
scope: {
label: '@',
tipo: '@',
acao: '&click'
},
controller: 'Controller as vm',
templateUrl: function (elem, attrs) {
return 'componentes/botao-' + (attrs.tipo || 'padrao') + '.html';
}
}
})
.controller('Controller', function () {
var vm = this;
vm.alertar = function (label) {
alert(label);
}
vm.autorizar =function (acao) {
if(confirm("Confirmar operação?")){
acao();
}else{
vm.alertar('Operação salvar cancelada...');
}
}
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment