为什么在此代码中使用$ http.get时不使用angular js ajax? [英] Why not working angular js ajax when $http.get use in this code?

查看:36
本文介绍了为什么在此代码中使用$ http.get时不使用angular js ajax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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 已弃用.

You should access response.data,also replace success with then,.success has been deprecated.

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

这篇关于为什么在此代码中使用$ http.get时不使用angular js ajax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆