使用 Angularjs 从 rss 呈现博客

Rendering Blog from rss using Angularjs

我正在尝试使用 Angularjs 找到在我的网站上打印我的 post 的最佳方法。我从 here. I have bloque of codes, list, etc.. you can see from here 得到 post。所以..我得到 Json 并将其发送到视图,您可以看到下面的代码:

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;
      });
  }]);

我遇到的第一个问题是当我尝试打印 {{post.content}} 时不呈现 html,我发现这是呈现代码

<div ng-bind-html="expression"></div>

但这对我不起作用。也应该是直接打印代码的简单方法或库,我指的是网站中的代码块。

谢谢。

如果要渲染HTML,需要包含ngSanitize模块:

angular.module('myController', ['ngSanitize']);

之后您将能够安全地呈现 HTML 内容。

演示: http://plnkr.co/edit/6V8TtmUUhYecQoF66wAj?p=info