如何在angularJS中保护我的JSON服务器数据?

如何在angularJS中保护我的JSON服务器数据?,angularjs,json,Angularjs,Json,如何在angularJS中保护我的JSON服务器数据 在控制器中,我使用的是JSON服务器数据的URL,那么,如何从客户端保护它呢 我的JSON服务器数据URL是 我的源代码是 <!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script> <body> <div

如何在angularJS中保护我的JSON服务器数据

在控制器中,我使用的是JSON服务器数据的URL,那么,如何从客户端保护它呢

我的JSON服务器数据URL是

我的源代码是

<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="customersCtrl"> 

<table>
  <tr ng-repeat="x in names">
    <td>{{ x.Name }}</td>
    <td><a href="" ng-click="SuperFunction('{{x.Name}}')">{{ x.Country }}</a></td>
  </tr>
</table>

</div>

<script>
var app = angular.module('myApp', []);
app.controller('customersCtrl', function($scope, $http) {
    $http.get("http://www.w3schools.com/angular/customers.php")
    .then(function (response) { $scope.names = response.data.records; });
    $scope.SuperFunction = function (id) {
        alert(id);
    };
});
</script>

</body>
</html>

{{x.Name}
var-app=angular.module('myApp',[]);
app.controller('customersCtrl',函数($scope,$http){
$http.get(“http://www.w3schools.com/angular/customers.php")
.then(函数(响应){$scope.names=response.data.records;});
$scope.SuperFunction=函数(id){
警报(id);
};
});

您无法保护前端代码,它对用户/黑客可见

保护信息的最佳方式是服务器端身份验证(登录)


但是api和api调用(通过开发工具)总是可见的

你想保护什么?黑客可以很容易地访问JS文件,从中他可以很容易地使用指定的URL获取JSON数据。如何保护数据不受黑客攻击?你无法保护客户端JavaScript内部的任何内容,你能做的最好的事情就是混淆“黑客”…在这种情况下,你指的是用户。这就是网络之美:查看源代码。你可以准确地看到和了解发生在你面前的事情。有很多方法可以混淆这些数据,但是要知道你违反了网络的一个原则。TBL以这种方式为我们所有人创建了网络,而不是为了让你从封闭/孤立/专有的废话中获利……)