Created
March 4, 2016 21:52
-
-
Save kristovatlas/3b2d0bc8d290531ed231 to your computer and use it in GitHub Desktop.
A simple example of an Angular injection using $scope.$eval
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- angular injection using $scope.$eval --> | |
<!DOCTYPE html> | |
<html ng-app> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.1.1/angular.js"></script> | |
<script type="text/javascript"> | |
function MyController($scope) { | |
$scope.hack_the_planet = function() { | |
$scope.myoutput = $scope.$eval($scope.myinput); | |
} | |
} | |
</script> | |
</head> | |
<body> | |
<div ng-controller="MyController"> | |
<input type="text" ng-model="myinput" /> | |
<button ng-click="hack_the_planet()">Hack The Planet</button> | |
<h1 ng-model="myoutput"> {{ myoutput }} </h1> | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment