JSFiddle - React, Tailwind, and code Playground

by gabs00

HTML

<div ng-app="myApp" ng-controller="MyController">
ID <input type="text" ng-model="data.id" ng-change="onIDChange()"/>
URL <input type="text" ng-model="data.url" ng-change="onManualUrlChange()"/>
</div>

JavaScript

angular.module('myApp',[])
.controller('MyController', ['$scope', function($scope){
	$scope.data = {
  	id:'',
    url:''
  }
  $scope.manualUrl = false;
  
  $scope.onIDChange = function(){
  	if(!$scope.manualUrl){
    	if($scope.data.id === ''){
      	$scope.data.url = '';
      } else {
    		$scope.data.url = "http://myurl/" + $scope.data.id + ".txt";
      }
    }
  }
  
  $scope.onManualUrlChange = function(){
  	$scope.manualUrl = true
  };
}]);