Skip to content

Instantly share code, notes, and snippets.

@sandropaganotti-zz
Forked from emadb/app.js
Last active August 29, 2015 14:11
Show Gist options
  • Save sandropaganotti-zz/1e69114e4734d7b407c1 to your computer and use it in GitHub Desktop.
Save sandropaganotti-zz/1e69114e4734d7b407c1 to your computer and use it in GitHub Desktop.
window.app = angular.module('myApp', []);
window.app.controller('mainController', function($scope){
$scope.title = "Demo";
$scope.$on('ready', function(){
$('#btn').click(function(){
console.log('Controller: click');
});
});
});
window.app.directive('myDir', [function () {
return {
restrict: 'E',
transclude: true,
scope: {
lblContext: "@"
},
templateUrl: 'dir.html',
link: function (scope, element, attrs) {
scope.$emit('ready');
}
};
}]);
<h1>I am a directive</h1>
<div class="container-fluid" ng-transclude>
</div>
<html>
<body ng-app="myApp" ng-view ng-controller="mainController">
<h2>{{title}}</h2>
<my-dir>
<p>
Content here.
<button id="btn">A button</button>
</p>
</my-dir>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.5/angular.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="app.js"></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment