Skip to content

Instantly share code, notes, and snippets.

@rettal
Last active January 3, 2016 12:28
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save rettal/8462662 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html data-ng-app="DemoApp">
<head>
<meta charset="utf-8">
<body>
<div class="container" data-ng-controller="SimpleController">
Name:
<br />
<input type="text" data-ng-model="name" /> {{name}}
<br />
<p data-ng-repeat="cust in customers | filter:name">
<div data-ng-bind-html="cust.name"></div>
</p>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.8/angular-sanitize.js"></script>
<script>
var demoApp = angular.module('DemoApp', ['ngSanitize']);
function SimpleController($scope) {
$scope.customers = [
{name: "<b>Daniel Stokes</b>", city:'Manchester'},
{name:'Paul Smith',city:'London'},
{name:'Gary Brown',city:'Dublin'},
{name:'Jon Doe',city:'Cardiff'}
]
}
demoApp.controller('SimpleController', SimpleController);
</script>
</body>
</html>
@rettal
Copy link
Author

rettal commented Jan 17, 2014

I posted this as I was struggling to output any HTML, found a solution here:

http://stackoverflow.com/questions/18340872/how-do-you-use-sce-trustashtmlstring-to-replicate-ng-bind-html-unsafe-in-angu

(I used the second solution , NOT the chosen answer)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment