JSFiddle - React, Tailwind, and code Playground

by lasith011

HTML

<script src="https://code.angularjs.org/1.2.13/angular.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.2.13/js/ngDialog.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.2.13/css/ngDialog-theme-default.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/ng-dialog/0.2.13/css/ngDialog.css">
<b>Instructions: </b>Click on the button to ad the items to open ngDialog<br /><br />
<div ng-controller="MyCtrl">
  <button ng-click="openDialog()">Add name</button>
  <div ng-repeat="name in names track by $index">{{name}}</div>
  <script type="text/ng-template" id="templateForm">
      <h3>Add to array</h3>
    name
    <input type="text" ng-model="varName" />    
    <button ng-click="cancel()">cancel</button>
    <button ng-click="submit()" ng-disabled="disable">submit</button>
  
</script>
  
</div>

JavaScript

var myApp = angular.module('myApp',['ngDialog']);

myApp.controller('MyCtrl', function ($scope, ngDialog) {
		$scope.names = [];
    $scope.openDialog = function(){
    	ngDialog.open({
      	scope: $scope,
        template: 'templateForm',
        closeByDocument: false,
        controller: 'PopUpController'
      });
    }
});
myApp.controller('PopUpController', function($scope, ngDialog, $timeout){
	$scope.cancel = function(){
  	ngDialog.close();
  };
  $scope.submit = function(){
  	$scope.disable = true;
  	//Some calculation
  	$timeout(function(){
    	$scope.names.push($scope.varName);
      ngDialog.close();
    }, 1000);  	
    $scope.disable = false;
  };
});