AngularJS は初めてで、フレームワークを理解しようとしており、基本的な CRUD アプリを構築しようとしています。既存のレコードを更新するために何が必要なのかわかりません。これが私のサービスです:
angular.module('appServices', ['ngResource']).
factory('App', function ($resource) {
var Item = $resource('App/:AppId', {
//Default parameters
AppId: '@id'
}, {
//Actions
query: {
method: 'GET',
isArray: true
},
getById: {
method: 'PUT'
},
update: {
method: 'POST'
}
});
return Item;
});
基本的な Get all クエリと getById を実行して編集フォームにデータを入力することはできますが、ここで行き詰まっています。getById のコード例を次に示します。
$scope.apps = App.query();
$scope.getEdit = function(AppId) {
App.getById({id:AppId}, function(app) {
$scope.original = app;
$scope.app = new App(app);
});
};
$scope.save = function() {
//What type of information should go here?
//Do I need to make changes to the appServices?
};
私は、既存の情報の更新に関する次のこと、または「アプリ」オブジェクトがAPIにどのように渡されるかがわからないだけだと思います.誰かが私を正しい方向に向けるか、簡単な更新方法を教えてもらえますか?