Created
June 8, 2011 15:50
-
-
Save vojtajina/1014686 to your computer and use it in GitHub Desktop.
Angular Simple Widget with descend(true)
This file contains hidden or 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
<!DOCTYPE HTML> | |
<html xmlns:ng="http://angularjs.org"> | |
<script type="text/javascript" src="http://code.angularjs.org/0.9.16/angular-0.9.16.min.js" ng:autobind></script> | |
<script type="text/javascript"> | |
angular.widget('my:test', function(element) { | |
// compile children elements ? | |
this.descend(true); | |
element.append('<button type="button" ng:click="testIt()">TEST</button>'); | |
}); | |
function Cntl() { | |
this.testIt = function() { | |
alert('It does work mate !'); | |
}; | |
} | |
</script> | |
<body ng:controller="Cntl"> | |
<my:test></my:test> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for this example, and your others. Learning AngularJS seems to require quite a bit of re-learning and re-thinking, and your posts have been the most helpful.