2015-04-17 34 views
0

我在我的項目上使用angular-fullstack。Angular-fullstack獲得發佈文章ID

$scope.saveArticle = function(article) { 
    Article.insert({ 
    //post stuff 
    }, function() { 
    //get the posted article ID 
    $location.path('/blog/ARTICLE_ID'); 
    }); 

如何獲取剛發佈的文章ID?

+2

難道你不能使用'文章'? – Satpal

+0

刪除了jquery標籤,因爲jquery在這裏沒有關係 – bipen

+0

@Satpal謝謝! – Hiero

回答

2

嘗試以下操作:

$scope.saveArticle = function(article) { 
    Article.insert({ 
     //post stuff 
    }, function (response) { 
     $location.path('/blog/' + response._id); 
    }) 
}; 

是如何運作的?

_id將是數據庫中ID列的名稱。如果您的ID列具有不同的名稱(例如ID,tableId等),則相應地更改它。