Angular: Empty Fiddle
http://angularjs.org/
by skeller88
HTML
<script src="http://code.angularjs.org/angular-1.0.0.js"></script>
<div ng-controller="MyCtrl">
{{hellos}}
</div>
JavaScript
var myApp = angular.module('myApp', []);
//service style, probably the simplest one
myApp.service('helloWorldFromService', function() {
this.sayHello = function() {
return "Hello, World!"
};
});
//factory style, more involved but more sophisticated
myApp.factory('helloWorldFromFactory', function() {
return function() {
return "Hello, World!"
}
});
function MyCtrl($scope, helloWorldFromFactory, helloWorldFromService) {
$scope.hellos = [
helloWorldFromFactory(),
helloWorldFromService.sayHello()
];
}