Demo entry 4108577

2

   

Submitted by anonymous on Mar 20, 2016 at 21:37
Language: HTML. Code size: 2.3 kB.

var app=angular.module('myApp', []);
app.directive ('attrrest', function(){
	return{
		restrict: 'A',
		link: function(){
			console.log("I am an atttribute")
		}
	}
})
.directive('elementrest', function(){
	return{
		restrict: 'E',
		link: function(){
			console.log("I am an element")
		}
	}
})
.directive('classrest', function(){
	return{
		restrict: 'C',
		link: function(){
			console.log("I am a class")
		}
	}
})
.directive('commentrest', function(){
	return{
		restrict: 'M',
		link: function(){
			console.log("I am a comment")
		}
	}
})
.controller('shieldCtrl',function($scope){
	$scope.shieldNames = [];
	this.addReigns = function(){
		$scope.shieldNames.push("Roman Reigns: Juggernaut");
	};
	this.addRollins = function(){
		$scope.shieldNames.push("seth Tollins: Architect");
	};
	this.addAmbrose = function(){
		$scope.shieldNames.push("Dean Ambrose: Lunatic Fringe");
	};
})
.directive('theshield', function(){
	return{
		restrict: 'E',
		scope: {},
		controller: 'shieldCtrl',
		link: function(scope, element,attr){
			element.bind('mouseenter', function(){
				console.log(scope.shieldNames);
			});
		}
	}
})
.directive('reigns', function(){
	return{
		require: 'theshield',
		link: function (scope, element,attr, shieldCtrl){
			shieldCtrl.addReigns();
		}
	}
})
.directive('rollins', function(){
	return{
		require: 'theshield',
		link: function (scope, element,attr, shieldCtrl){
			shieldCtrl.addRollins();
		}
	}
})
.directive('ambrose', function(){
	return{
		require: 'theshield',
		link: function (scope, element,attr, shieldCtrl){
			shieldCtrl.addAmbrose();
		}
	}
})
.directive('interactiveBtn', function(){
	return{
		restrict: 'A',
		
		link: function(scope, element, attr)
		{
			element.bind('mouseenter', function()
			{
				element[0].innerText = "Rolled Over";
			});
			element.bind('mouseleave', function(){
				element[0].innerText="Rolled Out"
			});
		}
	}
})
.directive('walterwhite', function()
{
	return {
		restrict: 'E',
		trasclude: true,
		link: function(scope, element, attr){
			/*console.log(scope);
			console.log(element);
			console.log(attr);*/
		}
	}
	/*return {
		restrict: 'E',
		transclude: true,
		template: '<h2>I am Heisenberg</h2>'
	}*/
});

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).