我在Django中使用angularjs。 这是我的angularjs脚本:
<script>
var app = angular.module('myApp',[]);
app.controller('myCtrl', function($scope, $http){
$scope.name = 'sh';
$http.get('http://127.0.0.1:8000/json/ls/').then(function(response){
$scope.code = response.status;
$scope.text = response.statusText;
$scope.data = response.data;
},function(){
$scope.message = 'not found!';
});
});
这是http://127.0.0.1:8000/json/ls/页面的结果:
{'record':[{'name':'your name','post':'dp'},{'name':'sdfsdfyour name','post':'sdfsfsfdp'},{'name':'your namefdsfsd','post':'dpsfdfsdf'},{'name':'your namesdfsdfs','post':'dpfsfdsfs'}]}
但是$http.get('http://127.0.0.1:8000/json/ls')
功能会向我显示$scope.message
的数据。并且您知道只有$ http.get()无法找到特定页面时才会显示此结果。请问有什么建议/解决方案吗?