Всем привет! Недавно начал изучать AngularJS.
Задача вот какая. Используя API вконтакте нужно вытянуть оттуда список новостей по запросу из текстовой строки используя метод newsfeed.search
Вот код index.html:
<!DOCTYPE html>
<html ng-app="testApp">
<head>
<title>Hismith</title>
<meta charset="utf-8">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/bootstrap-theme.css">
<script src="js/jquery-3.1.1.js"></script>
<script src="js/bootstrap.js"></script>
<script src="js/angular.js"></script>
<script src="js/controllers.js"></script>
</head>
<body ng-controller="Controller1">
<div class="container">
<div class="col-lg-8 col-lg-offset-4">
<form class="form-search">
<input type="text" class="input-medium search-query">
<button type="submit" class="btn">Найти</button>
</form>
<div class="result">
{{news.data[0]}}
</div>
</div>
</div>
</body>
</html>
Вот код controllers.js:
var myApp = angular.module('testApp',[]);//Ангуляр приложение
myApp.controller('Controller1', function($scope, $http){
$url = 'https://api.vk.com/method/newsfeed.search?q=погода&access_token=мой_токен_вконтакте&v=V';
// Simple GET request example:
$http({
method: 'GET',
url: $url
}).then(function successCallback(response) {
console.log('успех');
// this callback will be called asynchronously
// when the response is available
}, function errorCallback(response) {
console.log('ошибка');
// called asynchronously if an error occurs
// or server returns response with an error status.
});
});
Но почему то браузер в строке консоли пишет вот что:
XMLHttpRequest cannot load
https://api.vk.com/method/newsfeed.s...7f40049df4&v=V. No 'Access-Control-Allow-Origin' header is present on the requested resource.
Народ, помогите пожалуйста, как это лечится?