Skip to content

Instantly share code, notes, and snippets.

@oozman
Last active August 18, 2017 03:26
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 oozman/37dd20fcf69d2d495faf88377ba3cd6f to your computer and use it in GitHub Desktop.
Save oozman/37dd20fcf69d2d495faf88377ba3cd6f to your computer and use it in GitHub Desktop.
ng-directive
/**
* Toast directive. Ex: <toast msg="Some message." style="success|info|warning|danger"></toast>
*/
.directive('toast', [function () {
return {
restrict: 'E',
template: function (elem, attr) {
return '<div class="toast">\n' +
' <div class="{{ style }}" role="alert">{{msg}}</div>\n' +
'</div>';
},
scope: {
msg: '=msg',
style: '=style'
},
link: function (scope, element, attrs) {
scope.style = 'alert alert-' + scope.style;
}
};
}])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment