I want to open a ngx-select-dropdown on button click in angular component. Can someone have any idea how to do that?
I tried
#ViewChild('nexdropdown') nexdropdown: any = SelectDropDownModule;
clickFunction() {
this.carriercomponent.nativeElement.open();
//This results TypeError: Cannot read properties of undefined (reading 'open')
//I tried this too but this says TypeError: this.carriercomponent.open is not a function
this.carriercomponent.open();
}
Related
I have a trivia app that is importing an array of objects called "questions". I have used getElementById to capture each of the buttons, and also added click event listeners for the "checkAnswer" function below.
However, I am getting the error: Uncaught TypeError: can't access property "correct", answer is undefined. This happens with any button I click.
I am using type="module" within the script tag in the HTML file.
The buttons are populating the correct text, but are not console logging any text like it should.
"randomQuestion" is a global variable that is being generated in another function within the same file. This is what it looks like:
randomQuestion = questions[Math.floor(Math.random()*questions.length)];
function checkAnswer(bntIndex) {
answer = randomQuestion.answers[bntIndex];
if (answer.correct === true) {
console.log("Correct!");
} else {
console.log("Incorrect");
}
}
It's rather a warning than an error.
You are getting those because you don't export this function and also don't use it anywhere
When I run the below code in my extension:
let SpotifyPlayer, SpotifyLeftButton
SpotifyLeftButton = document.createElement("img")
SpotifyLeftButton.src = "chrome-extension://.../assets/skip1.png"
SpotifyLeftButton.className = "spotify-left-btn"
SpotifyLeftButton.title = "Click on this button to start the skip of the song."
SpotifyPlayer = document.getElementsByClassName("player-controls__buttons")[0]
SpotifyPlayer.appendChild(SpotifyLeftButton)
I get the following error, "Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'appendChild')".
However, when I run the code in the console, it works.
I thought that this error was occurring because the page wasn't fully loaded. However, the code still doesn't work even after wrapping it with window.onload () => {}.
I'm using the following code on Instagram follow request page to open each user in a new tab and then unfollow it.
https://www.instagram.com/accounts/access_tool/current_follow_requests
var i=0;
var unfollow="global";
var final="global";
var link=["link","link2"];
var proWindow=[""]
proWindow.length=0
link.length=0;
var ids = document.querySelectorAll(".-utLf");
for(i=0;i<ids.length;i++){
link.push('https://www.instagram.com/'+ids[i].innerText+'/');
console.log(link[i]);
proWindow[i]=window.open(link[i]);
}
and then the following code to unfollow each user:
for(i=0;i<ids.length;i++){
unfollow = proWindow[i].document.querySelector("button.sqdOP");
unfollow.click();
await new Promise(resolve => setTimeout(resolve, 1000));
final = proWindow[i].document.querySelector(".aOOlW");
final.click();}
console.log("Completed");
however, I'm seeing the following error on the console
Uncaught TypeError: Cannot read properties of undefined (reading 'push')
This preivously used to work fine but now is showing this error.
What change needs to be done to fix this code?
This error originates from trying to push something undefined to an array.
That could happend if the nodelist returned by the queryselector contains something with an undefined innertext for some reason.
This should work better:
if (ids[i].innerText){ // To check if the value is undefined
link.push('https://www.instagram.com/'+ids[i].innerText+'/');
console.log(link[i]);
proWindow[i]=window.open(link[i]);
}
When clicking the sidebar navigation link drop-down toggle instead of showing the drop-down list of items, I'm getting this error:
Uncaught TypeError: Cannot read property 'contains' of undefined
at sidebar.js:369
at Array.forEach (<anonymous>)
at t.n._toggleDropdown (sidebar.js:367)
at HTMLAnchorElement.<anonymous> (sidebar.js:497)
at HTMLDivElement.i (event-handler.js:116)
Checking the console the line that is generating the error is:
if (Default.dropdownAccordion === true) {
this._getAllSiblings(toggler.parentElement).forEach(element => {
if (element !== toggler.parentNode) {
if (element.classList.contains(CLASS_NAME_NAV_DROPDOWN)) { // line 369
element.classList.remove(CLASS_NAME_SHOW)
}
}
})
}
I'm using CoreUI (v3.2.0).
When I was looking for a solution I found that this could be a problem related to having different versions of the template but I have no idea how to fix it.
My button in my websites have onclick for function addNewSetPlanningReskilling().
But I CAN'T get DOMelement by using variable in my environment, in console i CAN.
function addNewSetPlanningReskilling(){
numberOfSets++;
console.log(numberOfSets); // here i have number as i want to have, for example 3,4,5..
document.querySelector(`[data-key='${numberOfSets}']`).style.display = 'block';
}
Uncaught TypeError: Cannot read property 'style' of null at addNewSetPlanningReskilling at HTMLButtonElement.onclick
I found solution for this :
change this :
document.querySelector(`[data-key='${numberOfSets}']`)
for this:
document.querySelector("[data-key='"+numberOfSets+"']")