Last active
August 29, 2015 13:56
Revisions
-
xuyuanme revised this gist
Feb 16, 2014 . 1 changed file with 7 additions and 7 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,16 +2,16 @@ angular.module("alert-directive", []) .directive('alert', function () { return { restrict: 'EA', // support to be used as an element or an attribute replace: true, // tells the compiler to replace the original directive's element with the template given by the template field template: '<div class="alert alert-{{type || \'info\'}}">' + '<button type="button" class="close" ng-click="close()">×</button>' + '<div ng-transclude></div>' + // the ng-transclude directive gets the transcluded elements and appends them to the element in the template on which it appears '</div>', transclude: true, // tells the compiler to extract the contents of the original <alert> element and make them available to be transcluded into the template scope: { // create an isolated scope type: '=', // the = symbol indicates that AngularJS should keep the expression in the specified attribute and the value on the isolated scope in sync with each other close: '&' // the & symbol indicates that the expression provided in the attribute on the element will be made available on the scope as a function } }; }); -
xuyuanme created this gist
Feb 16, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ angular.module("alert-directive", []) .directive('alert', function () { return { restrict: 'EA', replace: true, template: '<div class="alert alert-{{type || \'info\'}}">' + '<button type="button" class="close" ng-click="close()">×</button>' + '<div ng-transclude></div>' + '</div>', transclude: true, scope: { type: '=', close: '&' } }; });