Angular: Empty Fiddle
http://angularjs.org/
by sramnan
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<div ng-app="myApp">
<country>
<state>
<city>
</city>
</state>
</country>
</div>
JavaScript
var app = angular.module('myApp', []);
//myApp.directive('myDirective', function() {});
//myApp.factory('myService', function() {});
app.directive('country', function() {
return {
restrict: 'E',
controller: function() {
this.sayHi = function() {
console.log("hi");
};
}
}
});
app.directive("state", function() {
return {
restrict: "E",
require: "^country",
link: function(scope, element, attrs, countryCtrl) {
countryCtrl.sayHi();
}
};
});
app.directive("city", function() {
return {
restrict: "E",
require: "^country",
link: function(scope, element, attrs, countryCtrl) {
countryCtrl.sayHi();
}
};
});