Как мне поставить получить каталог $ object ["" 0 ""]. Projhours без синтаксиса err.AngularJS - PullRequest
0 голосов
/ 07 февраля 2019

Я новичок в этом, но мне нужно получить значение projhours из этого каталога в console.log () без синтаксической ошибки.на консоли chrome, когда я щелкаю правой кнопкой мыши на каталоге projhours, я получаю это ($object[""0""].projhours), но AngularJS явно не принимает [""0""], так как мне получить ТОЛЬКО значение projhours, которое будет отображаться в console.log ()?(предполагается, что это 41222)

код ниже прилагается, когда я набираю console.log() для переменной, которая имеет getlist.

var test = Restangular.allUrl('category/categoryNonProductiveTasks')
            .getList({weekFrom: vm.weekStart.slice(0, 2), weekTo: vm.weekEnd.slice(0, 2), year: vm.selectedYear})
          console.log(test)



Promise {$$state: {…}, call: ƒ, get: ƒ, restangularCollection: true, push: ƒ, …}
$$state: {status: 1, value: Array(1)}
$object: Array(1)
0:
addRestangularMethod: ƒ addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem)
all: ƒ all(parent, route)
allUrl: ƒ allUrl(parent, route, url)
clone: ƒ copyRestangularizedElement(element)
customDELETE: ƒ customFunction(operation, path, params, headers, elem)
customGET: ƒ customFunction(operation, path, params, headers, elem)
customGETLIST: ƒ fetchFunction(what, reqParams, headers)
customOperation: ƒ customFunction(operation, path, params, headers, elem)
customPATCH: ƒ (operation, elem, path, params, headers)
customPOST: ƒ (operation, elem, path, params, headers)
customPUT: ƒ (operation, elem, path, params, headers)
doDELETE: ƒ customFunction(operation, path, params, headers, elem)
doGET: ƒ customFunction(operation, path, params, headers, elem)
doGETLIST: ƒ fetchFunction(what, reqParams, headers)
doPATCH: ƒ (operation, elem, path, params, headers)
doPOST: ƒ (operation, elem, path, params, headers)
doPUT: ƒ (operation, elem, path, params, headers)
fromServer: true
get: ƒ getFunction(params, headers)
getList: ƒ fetchFunction(what, reqParams, headers)
getParentList: ƒ ()
getRequestedUrl: ƒ (current, what)
getRestangularUrl: ƒ (current, what)
head: ƒ headFunction(params, headers)
one: ƒ one(parent, route, id, singleOne)
oneUrl: ƒ oneUrl(parent, route, url)
options: ƒ optionsFunction(params, headers)
parentResource: null
patch: ƒ patchFunction(elem, params, headers)
plain: ƒ stripRestangular(elem)
post: ƒ postFunction(what, elem, params, headers)
project: []
projhours: 41222
put: ƒ putFunction(params, headers)
remove: ƒ deleteFunction(params, headers)
reqParams: null
restangularCollection: false
restangularized: true
route: "category/categoryNonProductiveTasks"
save: ƒ save(params, headers)
several: ƒ several(parent, route /*, ids */ )
trace: ƒ traceFunction(params, headers)
withHttpConfig: ƒ withHttpConfig(httpConfig)
yearofdate: 2018
__proto__: Object
addRestangularMethod: ƒ addRestangularMethodFunction(name, operation, path, defaultParams, defaultHeaders, defaultElem)
all: ƒ all(parent, route)
allUrl: ƒ allUrl(parent, route, url)
clone: ƒ copyRestangularizedElement(element)
customDELETE: ƒ customFunction(operation, path, params, headers, elem)
customGET: ƒ customFunction(operation, path, params, headers, elem)
customGETLIST: ƒ fetchFunction(what, reqParams, headers)
customOperation: ƒ customFunction(operation, path, params, headers, elem)
customPATCH: ƒ (operation, elem, path, params, headers)
customPOST: ƒ (operation, elem, path, params, headers)
customPUT: ƒ (operation, elem, path, params, headers)
doDELETE: ƒ customFunction(operation, path, params, headers, elem)
doGET: ƒ customFunction(operation, path, params, headers, elem)
doGETLIST: ƒ fetchFunction(what, reqParams, headers)
doPATCH: ƒ (operation, elem, path, params, headers)
doPOST: ƒ (operation, elem, path, params, headers)
doPUT: ƒ (operation, elem, path, params, headers)
fromServer: true
get: ƒ getById(id, reqParams, headers)
getList: ƒ fetchFunction(what, reqParams, headers)
getRequestedUrl: ƒ (current, what)
getRestangularUrl: ƒ (current, what)
head: ƒ headFunction(params, headers)
one: ƒ one(parent, route, id, singleOne)
oneUrl: ƒ oneUrl(parent, route, url)
options: ƒ optionsFunction(params, headers)
parentResource: null
patch: ƒ patchFunction(elem, params, headers)
plain: ƒ stripRestangular(elem)
post: ƒ postFunction(what, elem, params, headers)
putElement: ƒ putElementFunction(idx, params, headers)
remove: ƒ deleteFunction(params, headers)
reqParams: {weekFrom: "1 ", weekTo: "52", year: 2018}
restangularCollection: true
restangularized: true
route: "category/categoryNonProductiveTasks"
several: ƒ several(parent, route /*, ids */ )
trace: ƒ traceFunction(params, headers)
withHttpConfig: ƒ withHttpConfig(httpConfig)
length: 1
__proto__: Array(0)
call: ƒ promiseCall(method)
get: ƒ promiseGet(what)
push: ƒ promiseCall(method)
restangularCollection: true
__proto__: Object

1 Ответ

0 голосов
/ 08 февраля 2019

Ваш test является Обещанием, поэтому он не содержит ничего из вашего вывода.Вы можете получить доступ только к ответу, когда ваше обещание выполнено:

Restangular
    .allUrl('category/categoryNonProductiveTasks')
    .getList({
        weekFrom: vm.weekStart.slice(0, 2),
        weekTo: vm.weekEnd.slice(0, 2),
        year: vm.selectedYear
    })
    .then(function (response) {
        console.log(response, response[0].projhours)
    })
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...