Last active
October 11, 2016 02:35
-
-
Save gabrielfeitosa/d35552ec986aee14c3c67cb2d6408b83 to your computer and use it in GitHub Desktop.
Padronização dos componentes com AngularJS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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