Skip to content

Instantly share code, notes, and snippets.

@peteplays
Forked from anonymous/index.html
Created May 13, 2016 18:52
Show Gist options
  • Save peteplays/ad29d773f817a4f83868a97a2eb2db81 to your computer and use it in GitHub Desktop.
Save peteplays/ad29d773f817a4f83868a97a2eb2db81 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/heruqegofi
<!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>
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