Michael Bromley
www.michaelbromley.co.uk
@michlbrmly
<div my-directive>...</div>
<my-widget>...</my-widget>
Pretty familiar so far...
<body ng-app="myApp">
<div ng-controller="myCtrl">
<li ng-repeat="item in items">...</li>
<div ng-show="isVisible">...</div>
var ngShowDirective = ['$animate', function($animate) {
return function(scope, element, attr) {
scope.$watch(attr.ngShow, function ngShowWatchAction(value){
$animate[toBoolean(value) ? 'removeClass' : 'addClass'](element, 'ng-hide');
});
};
}];
.directive('myWidget', function() {
return {
restrict: 'E', // or A?..... or C? M?
templateUrl: 'myWidget.html'
};
});
// so I immediately improved my pagination component
<div dir-pagination></div> // Attribute = not so good
<dir-pagination><dir-pagination> // Element = better
<my-modal-dialog>
<h1>{{ dialog.title }}</h1>
<p>{{ dialog.message }}</p>
</my-modal-dialog>