<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script> </head> <body ng-app="_APPNAME_" ng-controller="_CONTROLLERNAME_"> <h2>_APPNAME_</h2> <input type="text" ng-model="value" /> <p> <button ng-click="save()">Save</button> <button ng-click="clear()">Clear</button> </p> <p>Saved Value: <span ng-bind="savedValueFunction()"></span></p> <script> var app = angular.module("_APPNAME_", []); app.controller("_CONTROLLERNAME_", function($scope) { $scope.value = ""; $scope.savedValue = ""; $scope.savedValueFunction = function() { return $scope.savedValue; }; $scope.clear = function() { $scope.value = ""; $scope.savedValue=""; }; $scope.save = function() { alert("Saved"); $scope.savedValue=$scope.value; }; }); </script> </body> </html>
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter