url,但我不明白如何從到的NodeJS角度的數據,在這裏我要離開我的代碼
App.js角
Var myApp = angular.module ('angularTodo', ['angularUtils.directives.dirPagination']);
MyApp.controller ('mainController', ['$ scope', '$ http', function ($ scope, $ http) {
$ Http.get ('/ api/all'). Then (function (res) {
$ Scope.pacientes = res.data;
$ Scope.sort = function (keyname) {
$ Scope.sortKey = keyname; // set the sortKey to the param passed
$ Scope.reverse =! $ Scope.reverse; // if true make it false and vice versa
}
}). Finally (function() {
$ Scope.example7 + = "(Finally called)";
});
}]);
MyApp.controller ('patient', ['$ scope', '$ http', function ($ scope, $ http)
$ Http.get ('/ patient /: id') .then (function (res) {
$ Scope.new = res.data.pk;
$ Scope.test = "test11";
}). Finally (function() {
$ Scope.example7 + = "(Finally called)";
});
}]);
Routes.js
App.get ('/ patient /: id', function (req, res) {
Var id = req.params.id;
Connection.query ('SELECT * FROM patient WHERE pat_id =?', [Id], function (err, data)
{
If (err)
Console.log ("Error Selecting:% s", err);
Res.json (data [0]);
Console.log (id);
Console.log (data);
});
});
App.get ('/ newinf /: id', isLoggedIn, function (req, res) {
Res.render ('informe.ejs', {user: req.user});
});
的問題是,$ http.get( '/患者/:ID')沒有接收到ID?我如何在angularjs中獲得url的id?
請修復你的代碼,變量名,函數中有很多不需要的空格... – Mistalis