<!doctype html> <html ng-app="demo"> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.3/angular.min.js"></script> <script type="text/javaScript"> angular.module('demo', []) .controller('Hello', function($scope, $http) { $scope.buttonTranslate = function(event) { $http.get('https://translate.googleapis.com/translate_a/single?client=gtx&sl=auto&tl=' + $scope.tl + '&dt=t&q=' + $scope.textToTranslate). then(function(response) { $scope.tranlation = response.data[0][0][0]; }); } }); </script> </head> <body> <div ng-controller="Hello"> Text to Translate: <input ng-model="textToTranslate" /><br /><br /> Target Language: <select name="users" ng-model="tl"> <option value="fr">French</option> <option value="de">German</option> <option value="ja">Japanese</option> <option value="es">Spanish</option> </select><br/><br/> <button ng-click="buttonTranslate()">Translate</button> <h1>{{tranlation}}</h1> </div> </body> </html>
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more