var App = angular.module('awesomeApp', []);
// just a quick template with an awesome tag name
App.directive('ca$#', function () {
return {
restrict: 'E',
link: function (s, e, a) {
console.log(a);
s.name = a.name;
s.result = a.result;
},
template: '<h1>{{name}}</h1><h2>{{name}}</h2><h3>{{name}}</h3><h6>{{result}}</h6>'
};
});
// attribute directive for fun and profit
App.directive('m0ney$', function () {
return {
restrict: 'A',
link: function (s, e, a) {
s.named = '$$$'
},
// Angular lesson learned:
// don't use the same scope variable name as another directive!
template: '<h1>{{named}}</h1><h2>{{named}}</h2>'
};
});
//
App.directive('awesome', function () {
return {
restrict: 'C',
link: function (s, e, a) {
s.squiggles = '~~~';
s.fundamentals = (function a(j) {
var arr = []
for (var i = 0; i < j; i++) {
arr.push(i)
}
return arr;
}(s.japanese.length));
},
// I can see myself abusing the comment directive
// just dumping whatever is in the directive scope
template: '<li style="display:block; position: relative; font-size: 14px;" ng-repeat="fun in fundamentals"><td>{{$index}} {{$first}} {{middle}} {{$last}} <h1 style="top: -5px; left: -20px; position:absolute; font-size: 20px; color: #f00">{{japanese[$index]}}</h1> {{person.job}}</li>'
};
});
// this one just adds a variable to the scope
// Seemed like a good idea at the time!
App.directive('ninja', function () {
return {
restrict: 'M',
link: function (s, e, a) {
console.log(a)
s.japanese = a.ninja;
console.log('scope', s)
}
};
});
App.directive('person', function () {
return {
restrict: 'M',
link:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.