私は依存関係を持つ角度ui-router
次午前$ routeparamsを使用していますangular1サービスに渡されていないangular-ui-router/1.0.3/
データは、私が
角度依存性の1.2.xの
angular.module('todoservice', [])
.factory('user', ['$http','$stateParams', function($http, $stateParams){
userDetails: function(id){
//:id is working when I pass static Id which is present in mongodb
return $http.get('/userDetails/display/:id', id);
//here is the problem i dont know how to pass id with angular to express(api is working perfectly)/
},
これは私の角度コントローラである
user.userDetails(id).success(function(data){ console.log("data from services to controller", data); $scope.userDetails_test = data; });
これはドキュメントhereを参照してください、あなたはid
patameterでサーバーからデータを取得しようとしているので、あなたが$http.post
を使用することができ、これが私の見解である
//todo._id==> working perfectly with getting an id in the table with ng-repeat
<a ui-sref="userDetails({id: todo._id})" ng-href = "userDetails/:todo._id" ng-click = "userDetails_scope()">userDetails</a>
あなたは '/( '$ http.getのようなURLにパラメータをCONCAT必要がありますuserDetails/display/'+ id); ' –
どこに' id'を渡すのですか? 'userDetail'状態?またはデータをフェッチするサーバー側 – Pengyy
サーバー側でデータを取得する場合、 – muthukumar