1

我正在使用一个示例,该示例将使用 Angular 和 Breezejs 显示来自 OData 的内容

索引.html

<!docttype html>
<html ng-app="app">
<head>
 <script src="datajs-1.0.3.js"></script>
</head>
<body>
<div ng-controller="LearnCtrl">
  <p ng-show="!results">Fetching...</p>
  <li ng-show="results" ng-repeat="result in results">
   <span>{{result.Login}}</span>
   <span>{{result.Email}}</span>
  </li>   
  </div> 

  <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.js"></script>
  <script src="http://sampleservice.breezejs.com/scripts/q.min.js"></script>
  <script src="http://sampleservice.breezejs.com/scripts/breeze.min.js"></script>
  <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.3/angular.min.js"></script>
  <script src="app.js"></script>

  </body>
  </html>

应用程序.js

 var app = angular.module('app', []);
 breeze.config.initializeAdapterInstance("dataService", "OData");
 breeze.config.initializeAdapterInstance("modelLibrary", "backingStore", true);
 app.controller("LearnCtrl", function($scope) {
  var manager = new breeze.EntityManager('http://localhost:8083/WordPress2.svc');

var query = new breeze.EntityQuery()
    .from("User");

manager.executeQuery(query).then(function(data){
   $scope.results = data.results;
   $scope.$apply();
}).fail(function(e) {
    alert(e);  
});
});

我正在使用 ISS7 服务器执行代码...当我说 localhost:8082...在 console.log 中它说

OPTIONS http://localhost:8083/WordPress2.svc/$metadata 501 (Not Implemented) datajs-1.0.3.js:1074
OPTIONS http://localhost:8083/WordPress2.svc/$metadata Origin http://localhost:8082 is not allowed by Access-Control-Allow-Origin. datajs-1.0.3.js:1074
 XMLHttpRequest cannot load http://localhost:8083/WordPress2.svc/$metadata. Origin http://localhost:8082 is not allowed by Access-Control-Allow-Origin. localhost/:1

应该为空:[] 为什么我收到此错误...请帮助我...这是我使用这些技术的第一个应用程序...

4

0 回答 0