Javascript 根据url参数以角度获取json
我想从mongoDB获取json。 我有一个服务器端,它根据“idstud”向我的客户端发送了json,我希望我的客户端以角度显示在屏幕上 这是我的服务器端(控制器): 我的服务器端(index.js): 我的客户端(控制器): var showStudentById=angular.module('showStudentById',[]) showtstudentbyid.controller('showtstudbyid'Javascript 根据url参数以角度获取json,javascript,angularjs,json,mongodb,Javascript,Angularjs,Json,Mongodb,我想从mongoDB获取json。 我有一个服务器端,它根据“idstud”向我的客户端发送了json,我希望我的客户端以角度显示在屏幕上 这是我的服务器端(控制器): 我的服务器端(index.js): 我的客户端(控制器): var showStudentById=angular.module('showStudentById',[]) showtstudentbyid.controller('showtstudbyid' ['$scope','$http',function($scope,
['$scope','$http',function($scope,$http) {
$http.get("http://localhost:3000/studentsById/:idstud").success(function(data){
$scope.studentByIdController = data;
console.log(data);
});
}]);
我的客户端html:
<html ng-app="showStudentById">
<head>
<title>student</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
</head>
<body ng-controller="showStudById">
<tbody>
<div>
<h1 class="text-center">All Students By Id</h1>
<div ng-repeat="student in studentByIdController">
<h2 class="text-center">name:{{student.name}}</h2>
<h2 class="text-center">id:{{student.idstud}}</h2>
<h2 class="text-center">grade:{{student.grade}}</h2>
<h2 class="text-center">year:{{student.year}}</h2>
<h2 class="text-center">coures:{{student.coures}}</h2>
<h2 class="text-center">--------------------------</h2>
</div>
.....
学生
所有学生凭身份证
姓名:{{student.name}
id:{{student.idstud}
年级:{{学生.年级}
年份:{{student.year}
课程:{{student.coures}
--------------------------
.....
try$scope.studentByIdController=data.data;没有使用它的return-me空数组,不是json有什么问题???你想知道如何从浏览器url在angular controller中填充“idstud”还是什么?你的console.log(数据)的输出是什么
?在Consolery$scope.studentByIdController=data.data中不工作;没有使用它的return-me空数组,也没有JSON。你有什么问题吗???你想知道如何从浏览器url或什么来填充Angle controller中的“idstud”吗?控制台中的console.log(data)
?在控制台中不工作
['$scope','$http',function($scope,$http) {
$http.get("http://localhost:3000/studentsById/:idstud").success(function(data){
$scope.studentByIdController = data;
console.log(data);
});
}]);
<html ng-app="showStudentById">
<head>
<title>student</title>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrap-theme.min.css">
</head>
<body ng-controller="showStudById">
<tbody>
<div>
<h1 class="text-center">All Students By Id</h1>
<div ng-repeat="student in studentByIdController">
<h2 class="text-center">name:{{student.name}}</h2>
<h2 class="text-center">id:{{student.idstud}}</h2>
<h2 class="text-center">grade:{{student.grade}}</h2>
<h2 class="text-center">year:{{student.year}}</h2>
<h2 class="text-center">coures:{{student.coures}}</h2>
<h2 class="text-center">--------------------------</h2>
</div>
.....