js调用一个ajax兼容的WCF服务

angular.js call an ajax compatible WCF service

本文关键字:WCF 服务 ajax 一个 调用 js      更新时间:2023-09-26

如何在angular.js控制器中调用ajax兼容的WCF服务?

我尝试将Jquery和Angular.JS结合起来,比如:

app.controller('ListUsersController', function () {
    var me = this;
    this.listusers = [];
    this.fill = function () {
       $.getJSON("Contact.svc/getjemploye", function (data) {
           me.listusers.push({id:"1",name:"Vinc"});
       });
    };
});

当我将用户推入listusers中时,看起来控制器无法看到我正在向列表添加内容,因此它不会再次显示列表(在html中,我无法看到我刚刚推入的新用户)。

Angular有自己的一组Ajax调用器。

$http({ method: "GET", url: "http://yoururlhere.com")
.success(function (response) {
  alert("success!");
});