I'd faced an issue related to $scope.$watch. Here is my code snippet.
$scope.$watch('vm.pageData.wti.price', function(value) {
filterWatcher.setWtiPrice(value);
}
vm.pageData.wti.price has price data, like $30.00
When executed code, I got this error:
Syntax Error: Token '.00' is an unexpected token at column 4 of the
expression [$30.00] starting at [.00].
It seems the value "$30.00" inside the variable "vm.pageData.wti.price" caused this error. Is it impossible to watch the data of this kind?
add a true argument after the function, this will watch an object inside the object
$scope.$watch('vm.pageData.wti.price', function(value) {
filterWatcher.setWtiPrice(value);
}, true);
Related
I'm trying to follow this tutorial.
Basically, I want to create my custom function that creates a folder if it not exists.
var makeDir = (path) => {
const file = Gio.file_new_for_path(path);
if (file.query_exists(path)) {
print(`Dir already exists ${path}`);
return;
}
print(`My Path: ${path}`);
// file.make_directory(path);
};
When I run this code I'm receiving an error:
Gjs-CRITICAL **: 17:35:17.161: JS ERROR: Error: Expected an object of type GCancellable for argument 'cancellable' but got type string
In the documentation I see that GCancellable is optional. So I have no idea why my code does not work. Haw can I make it work?
In the C documentation, "optional" means something else than it usually does in JS: it means it's optional to pass a real pointer as that argument, and you may also pass NULL.
The error message is complaining about a string because query_exists() does not take a path string argument. Check the JS documentation for the list of arguments accepted in JS: you should call file.query_exists(null).
I'm getting the following warning [Vue warn]: Error in nextTick: "TypeError: Cannot convert object to primitive value" followed by an error TypeError: Cannot convert object to primitive value.
This happens upon setting an object in the store. The data is set in the store correctly, the problem appear to be happening in the renderization of the page after the nextTick is happening.
The console log for the error shows:
at baseSetAttr (vue.esm.js:6811)
at setAttr (vue.esm.js:6786)
at Array.updateAttrs (vue.esm.js:6740)
at patchVnode (vue.esm.js:6312)
at updateChildren (vue.esm.js:6188)
On the file vue.esm.js:6811 I get the following:
function baseSetAttr(el, key, value) {
if (isFalsyAttrValue(value)) {
el.removeAttribute(key);
} else {
// #7138: IE10 & 11 fires input event when setting placeholder on
// <textarea>... block the first input event and remove the blocker
// immediately.
/* istanbul ignore if */
if (isIE && !isIE9 && el.tagName === 'TEXTAREA' && key === 'placeholder' && value !== '' && !el.__ieph) {
var blocker = function (e) {
e.stopImmediatePropagation();
el.removeEventListener('input', blocker);
};
el.addEventListener('input', blocker); // $flow-disable-line
el.__ieph = true;
/* IE placeholder patched */
}
el.setAttribute(key, value); <--- The error happens here
}
}
I wish I could give more details to this question but I don't have any idea where or why this error is happening directly on my code. I have two pages using the same service, one render it correctly and the other happens this error. I have looked and made sure that both pages are exactly the same but this only happens in one
The answer will seem something extremely stupid but if anyone has an answer on why this happens I will gladly accept the answer.
The problem happens on this line of code on my implemented code:
<template #results="{ items, loading, sort, onSort, orderedHeaders, onColumnOrderChange }">
<order-summary :sort="sort"/>
The component order-summary doesn't have a prop sort. Upon removing of the prop sort everything works correctly.
<template #results="{ items, loading, sort, onSort, orderedHeaders, onColumnOrderChange }">
<order-summary/>
If anyone would have an explanation on why this happens I would gladly accept the answer
I also encountered the same problem. Although I don’t know what caused the problem, I can use
JSON.parse(JSON.stringify(***))
to solved
The reason is this: when parent component pass a prop to child component, and when child component did not receive the prop by registering prop filed, vue will think call prop.toString and put the value to the child's DOM element.
sth like this:
<div sort="[object Object]"></div>
and if the sort prop does have toString method, it will throw the Error you encoutered.
eg:
var a = Object.create(null);
var b = `${a}`, // TypeError: Cannot convert object to primitive value
Originally asked by Sashkan on the Oboe.js Github issues:
I'm getting a stremedResponse from a distant API. When I make an ajax call, I get the following response :
{"company_id":"3e1f975601f59090decc8f2d5ced72010162e481","airplane_type_id":"c10143316664f220a5cb87950b3dbac8794e2b15","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:44:00","duration":"00:59","availability":true}]},{"company_id":"3e1f975601f59090decc8f2d5ced72010162e481","airplane_type_id":"opfr8976xwqs54321zdickv678654xckvjfdf025","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:45:00","duration":"01:00","availability":true}]},{"company_id":"3e1f975601f59090decc8f2d5ced72010162e48e","airplane_type_id":"2368c24e9980e4eb9ccd986f32df884e5bd58707","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:50:00","duration":"01:05","availability":true}]}
But when I use oboe, only the first one is displayed, and immediately after, I get the following oboe error:
thrown: Error: Bad value Ln: 1 Col: 65 Chr: , at Error (native) at emitError (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:636:20) at handleData (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:816:20) at applyEach (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:497:20) at emit (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:2042:10) at XMLHttpRequest.handleProgress (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:1253:10)
message: "Bad value↵Ln: 1↵Col: 65↵Chr: ,"
stack: (...)
get stack: ()
set stack: ()
__proto__: DefineError.bh
Any idea why ?
Answer provided by JuanCaicedo
I think that response is invalid json, which you can verify by plugging it in to http://jsonlint.com/. It looks like it's three comma-separated objects. I think it's meant to be an array? If so, just add a [ at the start of the first object and a ] at the end of the last object.
Oboe is able to pick items out of a top-level array. Call .node('[*]', function(){...}).
The code I am getting the error for, after doing research I can not understand why this error keeps coming up. The line of code was working before but now this is crashing my entire project.
function HomePageView_GetActiveTopicParentId(id) {
return $("#" + id).attr("egain-parent-identifier");
}
the second set of code
function HomePageController_TopicsViewChanged(id) {
sessionStorage.setItem(CURRENT_TOPIC_PARENT_ID, HomePageView_GetActiveTopicParentId(id));
sessionStorage.setItem(CURRENT_TOPIC_ID, HomePageView_GetActiveTopic(id));
$.mobile.changePage("#ViewTopicPage");
}
The problem is that id needs to be a string but it is some other type of object. Where is your HomePageController_TopicsViewChanged function being called, and what is being passed in as the id parameter?
I've got a problem in AngularJS where $scope.$watchCollection() throws an error. I've reduced my code to the point where it's exactly the same as example code in the docs (http://docs.angularjs.org/api/ng.$rootScope.Scope#$watchCollection), and the error is still thrown:
function OverviewCtrl($scope) {
$scope.names = ['igor', 'matias', 'misko', 'james'];
$scope.dataCount = 4;
$scope.$watchCollection('names', function(newNames, oldNames) {
$scope.dataCount = newNames.length;
});
}
I get the error
'undefined' is not a function (evaluating '$scope.$watchCollection('names', function(newNames, oldNames) {
$scope.dataCount = newNames.length;
})')
I have no idea what the problem could possibly be. I'm doing exactly what the docs say, except I'm putting it in a controller, but it seems this code is intended for use in controllers. So what's the problem here?
You could also use the following syntax :
$scope.$watch('myCollection', function(value, oldValue) {
// insert awesome code here
}, true);
The true parameter tells AngularJS to "deepwatch" the value.