JSFiddle - React, Tailwind, and code Playground

by vojtajina

HTML

<script src="http://ci.angularjs.org/job/angular.js-misko/393/artifact/build/pkg/0.10.7-6e9a6630/angular-0.10.7-6e9a6630.min.js"></script>
<div ng:app="MyServiceModule">
 <div ng:controller="myController">
 <p>Let's try this simple notify service, injected into the controller...</p>
 <input type="text" ng:model="message" />
 <button ng:click="notify(message);">NOTIFY</button>
 </div>
</div>

JavaScript

angular.
 module('MyServiceModule', []).
 factory('notify', ['$window', function(win) {
    var msgs = [];
    return function(msg) {
      msgs.push(msg);
      if (msgs.length == 3) {
        win.alert(msgs.join("\n"));
        msgs = [];
      }
    };
  }]);

function myController($scope, notify) {
  // just publishing the service to the scope
  $scope.notify = notify;
  $scope.message = 'test';
}