-
-
Save sandropaganotti-zz/1e69114e4734d7b407c1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | |
} | |
}; | |
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>I am a directive</h1> | |
<div class="container-fluid" ng-transclude> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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