JSFiddle - React, Tailwind, and code Playground
by Santosh Thakur
HTML
<div ng-app="MyApp">
<div ng-controller="StarWarsController">
{{luke}}
</div>
</div>
JavaScript
//Controller
var module = angular.module('MyApp', [
'MyApp.services',
'MyApp.controllers'
]);
module.controller('StarWarsController', function($scope, VaderService) {
var luke = new VaderService('luke');
$scope.luke = luke.speak();
});
//factory Services
var module = angular.module('MyApp.services', []);
module.factory('VaderService', function() {
var VaderClass = function(padawan) {
this.name = 'Santosh';
this.speak = function() {
return 'Join the dark side ' + this.name;
}
}
return VaderClass;
});