I'm having trouble with the simple basics of angular directives and I was hoping for the most basic example of how to write an new ng-show directive. ie. I want to write directive ng-show2 to work the same as ng-show.
I get confused because in the angular.js file, the directive is defined like this:
var ngShowDirective = ngDirective(function(scope, element, attr){
scope.$watch(attr.ngShow, function(value){
element.css('display', toBoolean(value) ? '' : 'none');
});
});
but then most of the directive examples I see are written like this:
var myApp = angular.module('myApp', []);
myApp.directive('ngShow2', function() {
return {
replace: true,
restrict: 'A',
link: function(){....}
});
what exactly is corresponding with what?