angularjs - 为什么在这段代码中使用 $http.get 时不使用 Angular js ajax ?

标签 angularjs

var app = angular.module("mymodule",[]);

app.controller("employeeController",function($scope,$http){
    var url ="data/records.json";

    $http.get(url).success(function(response){
        $scope.employees =response;

    });

});

最佳答案

您应该访问response.data,同时将 success 替换为 then,.success 已被弃用。

$http.get(url).then(function(response){
        $scope.employees =response.data;
});

关于angularjs - 为什么在这段代码中使用 $http.get 时不使用 Angular js ajax ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43051175/

相关文章:

javascript - 对象属性值作为类名,ng-class

javascript - 使用 json feed 和传递的数据在 Angular 中获取正确的记录

AngularJS $routeChangeSuccess 回调参数

mongodb - Restangular 为以 "$"开头的 key 发送空负载

javascript - 用于显示输入错误的 AngularJS 表单验证指令

javascript - 将 AngularJS 中的时间戳格式化为自定义要求

javascript - AngularJS ng 绑定(bind)不起作用 - 无法设置未定义的属性

javascript - 如何制作 Angularjs 嵌套路由?

javascript - 如何在 Angular 中删除 JSON 对象中的对象?

AngularJS 无需重新加载即可进入状态并且具有没有值的参数