Angular - Module
Module with controller, filter, and directive.
by Sorfal
HTML
<script src="http://code.angularjs.org/angular-1.0.1.js"></script>
<body ng-app="myApp" ng-controller="myCtrl">
<input ng-model="msg" />
<p my-dctv >
{{msg | myUpperFilter }}
</p>
</body>
JavaScript
// the main (app) module
var myApp = angular.module("myApp", []);
// add a controller
myApp.controller("myCtrl", function($scope) {
$scope.msg = "hello world";
});
// add a filter
myApp.filter("myUpperFilter", function() {
return function(input) {
return input.toUpperCase();
}
});
// add a directive
myApp.directive("myDctv", function() {
return function(scope, element, attrs) {
element.bind("mouseenter", function() {
element.css("background", "yellow");
});
element.bind("mouseleave", function() {
element.css("background", "none");
});
}
});