Reputation: 3545
I'm trying to find the best way to print my posts in my website using Angularjs. I get the post from here. I have bloque of codes, list, etc.. you can see from here. So.. I get the Json and I send it propely to the view, you can see the code below:
myController.controller('BlogCtrl', ['$scope', '$http',
function ($scope, $http) {
$http.get('http://pipes.yahoo.com/pipes/pipe.run?_id=31e0037a4869eeb55f58c22114816864&_render=json')
.success(function(data){
$scope.posts = data.value.items;
}).
error(function() {
$scope.error = true;
});
}]);
First problem I got is when I try to print the {{post.content}} doesn´t render the html, I found this to render the code
<div ng-bind-html="expression"></div>
but it´s not working for me. Also should be a easy way or a library to print the code directly, I mean the bloque of code like in the website.
Thanks.
Upvotes: 1
Views: 41
Reputation: 193271
If you want to render HTML, you need to include ngSanitize
module:
angular.module('myController', ['ngSanitize']);
After that you will be able to safely render HTML contents.
Demo: http://plnkr.co/edit/6V8TtmUUhYecQoF66wAj?p=info
Upvotes: 1