-
-
Save peteplays/ad29d773f817a4f83868a97a2eb2db81 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/heruqegofi
This file contains 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.0/angular.min.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Plays Angular</title> | |
</head> | |
<body ng-app='app'> | |
<div ng-controller='cont'> | |
<br><br> | |
{{hello}} | |
<br><br> | |
<textarea ng-model='theInput'name="" id="" cols="50" rows="10"></textarea> | |
<br> | |
<button ng-click='sendInput(theInput);'> | |
Send Data | |
</button> | |
<br><br> | |
<p ng-bind-html="workHTML | keepHtml"></p> | |
</div> | |
<script id="jsbin-javascript"> | |
angular.module('app', []) | |
.controller('cont', function($scope, $sce) { | |
$scope.hello = 'Keep new lines entered in a textarea when displayed on a UI'; | |
$scope.sendInput = function(val) { | |
$scope.workHTML = val; | |
}; | |
}) | |
.filter('keepHtml', function($sce) { | |
return function(val) { | |
var getNewLines = val.replace(/\n/g, "<br>"); | |
return $sce.trustAsHtml(getNewLines); | |
}; | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">angular.module('app', []) | |
.controller('cont', function($scope, $sce) { | |
$scope.hello = 'Keep new lines entered in a textarea when displayed on a UI'; | |
$scope.sendInput = function(val) { | |
$scope.workHTML = val; | |
}; | |
}) | |
.filter('keepHtml', function($sce) { | |
return function(val) { | |
var getNewLines = val.replace(/\n/g, "<br>"); | |
return $sce.trustAsHtml(getNewLines); | |
}; | |
});</script></body> | |
</html> |
This file contains 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.module('app', []) | |
.controller('cont', function($scope, $sce) { | |
$scope.hello = 'Keep new lines entered in a textarea when displayed on a UI'; | |
$scope.sendInput = function(val) { | |
$scope.workHTML = val; | |
}; | |
}) | |
.filter('keepHtml', function($sce) { | |
return function(val) { | |
var getNewLines = val.replace(/\n/g, "<br>"); | |
return $sce.trustAsHtml(getNewLines); | |
}; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment