http get 获取参数

This commit is contained in:
luchenqun 2016-10-20 23:25:28 +08:00
parent eafd1a4035
commit f049bb2b39
4 changed files with 14 additions and 4 deletions

View File

@ -2,7 +2,8 @@ app.controller('bookmarksCtr', ['$scope', '$filter', 'bookmarkService', function
$scope.bookmarks = []; // 书签数据
// 获取书签数据
bookmarkService.getBookmarks().then(
var pageId = 1;
bookmarkService.getBookmarks(pageId).then(
function(data) {
console.log(data);
$scope.bookmarks = data;

View File

@ -3,6 +3,13 @@ app.controller('menuCtr', ['$scope', '$state', function($scope, $state) {
$scope.selectLoginIndex = 0; /**< 默认登陆之后的选择的菜单索引,下表从 0 开始 */
$scope.selectNotLoginIndex = 0; /**< 默认未登陆之后的选择的菜单索引,下表从 0 开始 */
/**
* @todo http://stackoverflow.com/questions/31449948/ui-router-state-go-not-working
*/
if($scope.login){
setTimeout(()=>{ $state.go('bookmarks') }, 0);
}
// 登陆之后显示的菜单数据。uiSerf内部跳转链接。
$scope.loginMenus = [
{uiSref:'bookmarks', title:'我的书签'},

View File

@ -11,10 +11,10 @@ app.factory('bookmarkService', ['$http', '$q', function($http, $q) {
};
// Return a promise object.
function getBookmarks() {
function getBookmarks(pageId) {
var def = $q.defer();
$http.get('/api/bookmarks')
$http.get('/api/bookmarks/'+pageId)
.success(function(data) {
def.resolve(data);
})

View File

@ -1,7 +1,9 @@
var api = require('express').Router();
api.get('/bookmarks', function (req, res) {
api.get('/bookmarks/:pageId', function (req, res) {
console.log('hello query', JSON.stringify(req.params.pageId));
var data = [
{title:'谷歌', description:'一个网站', url:'https://www.google.com.hk/', tags:['搜索','常用']},
{title:'百度', description:'二个网站', url:'https://www.baidu.com/', tags:['搜索','常用']},