使用 jsonp angularjs 从 github 访问自述文件

access readme files from github using jsonp angularjs

我正在开发 angular 需要显示来自 GitHub 的 readme.md 文件的应用程序 是否可以通过 angular 中的 Json 回调获取 我尝试了存储库,我明白了,但是 readme.md 文件如何

我看了例子githubapidocumentation.

jsfiddle.

上的实例

angular.module('ExampleApp', [])
  .controller('ExampleController', function($scope, Slim,$sce) {
    Slim.getReadme().then(function(resp) {
      $scope.readme = $sce.trustAsHtml(resp.data);
    }).catch(function(resp) {
      console.log("catch", resp);
    });
  })
  .service('Slim', function($http) {
    return {
      getReadme: function() {
        return $http.get("https://api.github.com/repos/slimphp/Slim/readme", {
          headers: {
            "Accept": "application/vnd.github.v3.raw"
          }
        });
      }
    };
  });
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="ExampleApp">
  <div ng-controller="ExampleController">
    <pre ng-bind-html="readme"></pre>
  </div>
</div>

当然要漂亮的展示markdown.

例如angular-markdown-directive