JSFiddle - React, Tailwind, and code Playground

by Stefano Bertoli

HTML

<div ng-app="myApp">
    <div ng-controller="HelloController">
        <p ng-click="showAlert()">
            {{greeting.text}}, World
        </p> 
    </div>
</div>

JavaScript

var app = angular.module("myApp", []);

app.factory("myAlert", function () {
    var myAlert = {//variabili json,  con associate funzioni
        show: function (message) {
            alert(message); 
             },
          write: function (message) {
            console.log(message);
             }        
    };
    return myAlert;
});

app.controller("HelloController", [
    "$scope", "myAlert", 
    function ($scope, myAlert) { 
        $scope.greeting = { 
            text: "Hello" 
        };
        $scope.showAlert=function()
        {
            myAlert.show("test");
       // myAlert.write("console");
        myAlert.show($scope.greeting.text);
        };
    }
]);