jsonp call raw gist in angular
errors because response is being eval'd
HTML
<link rel="stylesheet" href="https://gist.github.com/assets/embed-0af287a4b5c981db301049e56f06e5d3.css">
<div ng-app>
<div ng-controller="mainCtrl">
<button ng-click="makeRequest(0)">make request 1</button>
<button ng-click="makeRequest(1)">make request 2</button>
<h2>Response:</h2>
<div ng-bind-html-unsafe="response.div"></div>
<pre class="gist">{{responseData}}</pre>
</div>
</div>
JavaScript
var rawurl = ["https://gist.githubusercontent.com/ankoor7/9651ae3d423516f97f46/raw/07c4fa1c57e29526f983f822d4435187d3fc0110/code_test_ubiuity_press", "https://gist.github.com/4665900.json"];
function mainCtrl($scope, $http) {
$scope.makeRequest = function (num) {
$http({
url: rawurl[num] + "?callback=JSON_CALLBACK",
method: "JSONP"
}).then( function ( response ) {
var fileData = angular.element(response.data.div)[0].querySelector('.file-data'),
lines = fileData.querySelectorAll('.line'),
txt = '';
angular.forEach(lines, function(el, index) {
txt += el.innerText + '\n';
});
$scope.responseData = txt;
});
}
}