Regarding header footer in another module in angular

I am a new of Angular. I created header, footer and sidebar. And I was create dashboard component if I use in this dishoard component its works good. So it is working in component. then I created a module for employee. if i use Header Footer Sidebar in this employee module means its shows error

  1. If ‘app-header’ is an Angular component, then verify that it is part of this module.
  2. If ‘app-header’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the ‘@NgModule.schemas’ of this component to suppress this message.

1


src/app/employee/list-employee/list-employee.component.ts:5:16
  5   templateUrl: './list-employee.component.html',
                   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Error occurs in the template of component ListEmployeeComponent.


Error: src/app/employee/list-employee/list-employee.component.html:2:1 - error NG8001: 'app-sidebar' is not a known element:
1. If 'app-sidebar' is an Angular component, then verify that it is part of this module.
2. If 'app-sidebar' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.

2 <app-sidebar></app-sidebar>

src/app/employee/list-employee/list-employee.component.ts:5:16
5 templateUrl: ‘./list-employee.component.html’,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component ListEmployeeComponent.

Error: src/app/employee/list-employee/list-employee.component.html:514:9 – error NG8001: ‘app-footer’ is not a known element:

  1. If ‘app-footer’ is an Angular component, then verify that it is part of this module.
  2. If ‘app-footer’ is a Web Component then add ‘CUSTOM_ELEMENTS_SCHEMA’ to the ‘@NgModule.schemas’ of this component to suppress this message.

514
~~~~~~~~~~~~

src/app/employee/list-employee/list-employee.component.ts:5:16
5 templateUrl: ‘./list-employee.component.html’,
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Error occurs in the template of component ListEmployeeComponent.

Please help me to sort out this error.

JavaScript weekday list get

I need to create a JavaScript function for the below requirements. I need to get every week day date list. If you know nodeJs package tell me that. Thank you for your attention.

Example - 
 2022-01-03
 2022-01-04
 2022-01-05
 2022-01-06
 2022-01-07

 2022-01-10
 2022-01-11
 2022-01-12
 2022-01-13
 2022-01-14 
 ..........
 ..........
 until year-end

like this pattern (only Monday to Friday)

Sorting the array of string based on the custom order

I have the array of strings that I want to sort in a custom order
My array looks like this

[“E”, “D”, “CC”, “C”, “B”, “BB”, “BBB”, “A”, “AA”]

My expected result should look like this
[“AA”, “A”, “BBB”, “BB”, “B”, “CC”, “C”, “D”, “E”]

I tried to sort using the default sort() function but it didn’t give me expected results. So please give your suggestions

Importar la librería

No se encontró ningún archivo de declaración para el módulo ‘jspdf’. ‘D:/proyectoTitulaciòn/angularPDF/WordPdf/node_modules/jspdf/dist/jspdf.min.js’ tiene un tipo “any” de forma implícita.

pequeño ejemplo:

    import { Component } from '@angular/core';
    import jspdf from 'jspdf';
    import html2canvas from 'html2canvas';

    @Component({
      selector: 'app-root',
      templateUrl: './app.component.html',
      styleUrls: ['./app.component.css']
    })
    export class AppComponent {
      title = 'WordPdf';
      constructor() {
        this.downloadPDF();
      }
      public downloadPDF(): void {
        const doc = new jspdf();

doc.text('Hello world!', 10, 10);
doc.save('hello-world.pdf');

}
}

Why `queryObjects()` in chrome console returns undefined but then results are printed out?

I executed the function queryObjects(WebSocket.prototype) in chrome console, which was promised to return an array of existing websockets on that page. However the return value is undefined, then after a while the expected result was printed out. What happens?

> queryObjects(WebSocket.prototype)
< undefined
  Array(1)
  ...

It seems that this function has no return value but just prints out the query result.

Change the pattern of an input to allow only multidates

I have a field in my form. That field has to accept multidates, for that I am using:

$("#myInput").datepicker({
    format: "dd/mm/yyyy",
    multidate: true,
    templates: {
        rightArrow: '&#62;',
        leftArrow: '&#60;'
    }
});

<input type="text" id="myInput" name="myInput" placeholder="DD/MM/YYYY" class="form-control" autocomplete="off">

It works great, but I would like to prevent the user to input some illegal character with some regex pattern.

I’ve found some alphanumeric examples, but could not find an example for multidate. The idea is accepting numbers [0-9] and the characters "," and "/" only.

I also found this example for a single date, and I tried it but it did not work for multiple dates:

^(0?[1-9]|1[012])[- /.](0?[1-9]|[12][0-9]|3[01])[- /.](19|20)dd$

The accepted format is this: DD/MM/YYYY,DD/MM/YYYY,DD/MM/YYYY

E.g.

23/01/2022,25/01/2022,27/01/2022

why icon is showing on above description while sharing?

I am sharing my website on whatapps from mobile to another mobile . Don’t know why my icon come on top.

My website url :

https://staging.ezylegal.in/legal-consultation

enter image description here

I used like this

<meta property='og:image' content='https://ezylegal.in/images/ezylogo.jpeg'/>
      <meta property="og:image:width" content="200" />
      <meta property="og:image:height" content="200" />

but when I am sharing another web site from my mobile to another mobile . it looks good. Icon show in left side of title and description

link : https://vakilsearch.com/. it is working fine as expected .

why my site icon goes to top while sharing from mobile.
enter image description here

Fetching data using a async function in react [duplicate]

I have been trying to create a table from an array of objects. I’m able to console the data inside the async function. But I couldn’t console it outside.

My code :

useEffect(() => {
  listingCampaignsModels()
}, []);


async function listingCampaignsModels() {
    const apiData = await DataStore.query(Campaign);
    console.log(apiData);
    console.log(typeof(apiData));
    return apiData;
  };

When I tried to console apiData outside, it returns apiData is not defined error.

The data looks like this :

[Model, Model, Model, Model, Model, Model]

Each Model looks like :

-> 1: Model {id: 'c40d6b22-840f-467a-909c-7b2b19960ffb', campaignOwner: 'eumagnas', campaignName: "mollitlab", startDate: "2022/08/15", endDate: "2022/10/25", expectedRevenue: 25, budgetedCost: 27, actualCost: 28}

I want loop through all the Models and create a table as :

Campaign Owner Campaign Name Start Date End Date Expected Revenue Budgeted Cost Actual Cost
eumagnas mollitlab 2022/08/15 2022/10/25 25 27 28

props.history.push() not working. Not able to route

I am trying to learn GraphQL. But I am stuck at props.history.push. I am not able to route it to another page.

Register.js

import React, { useState }  from 'react'
import {  Row, Col, Form, Button } from 'react-bootstrap'
import { gql, useMutation } from '@apollo/client';

const REGISTER_USER = gql`
  mutation register(
    $username: String!
    $email: String!
    $password: String!
    $confirmPassword: String!
  ) {
    register(
      username: $username
      email: $email
      password: $password
      confirmPassword: $confirmPassword
    ) {
      username
      email
      createdAt
    }
  }
`

export default function Register(props) {
  const [variables, setVariables] = useState({
    email: '',
    username: '',
    password: '',
    confirmPassword: '',
  })
  const [errors, setErrors] = useState({})

  const [registerUser, { loading }] = useMutation(REGISTER_USER, {
    update: (_, __) => props.history.push('/login'),
    onError: (err) => setErrors(err.graphQLErrors[0].extensions.errors),
  })

  const submitRegistrationForm= (e) => {
    e.preventDefault()

    registerUser({ variables })
  }

    return (
        <Row className="bg-white py-5 justify-content-center">
        <Col sm={8} md={6} lg={4} >

          <h1 className="text-center">
            Register
          </h1>

          <Form onSubmit={submitRegistrationForm}>
          <Form.Group className="mb-3">
            <Form.Label className={errors.email && 'text-danger'}>
              {errors.email ?? 'Email address'}
            </Form.Label>
            <Form.Control
              type="email"
              value={variables.email}
              className={errors.email && 'is-invalid'}
              onChange={(e) =>
                setVariables({ ...variables, email: e.target.value })
              }
            />
            
          </Form.Group>
          <Form.Group className="mb-3">
            <Form.Label className={errors.username && 'text-danger'}>
              {errors.username ?? 'Username'}
            </Form.Label>
            <Form.Control
              type="text"
              value={variables.username}
              className={errors.username && 'is-invalid'}
              onChange={(e) =>
                setVariables({ ...variables, username: e.target.value })
              }
            />
          </Form.Group>
          <Form.Group className="mb-3">
            <Form.Label className={errors.password && 'text-danger'}>
              {errors.password ?? 'Password'}
            </Form.Label>
            <Form.Control
              type="password"
              value={variables.password}
              className={errors.password && 'is-invalid'}
              onChange={(e) =>
                setVariables({ ...variables, password: e.target.value })
              }
            />
          </Form.Group>
          <Form.Group className="mb-3">
            <Form.Label className={errors.confirmPassword && 'text-danger'}>
              {errors.confirmPassword ?? 'Confirm password'}
            </Form.Label>
            <Form.Control
              type="password"
              value={variables.confirmPassword}
              className={errors.confirmPassword && 'is-invalid'}
              onChange={(e) =>
                setVariables({
                  ...variables,
                  confirmPassword: e.target.value,
                })
              }
            />
          </Form.Group>

            <div className="text-center">
              <Button variant="success" type="submit" disables={loading}>
                  {loading ? 'loading..':'Register'}
               
              </Button>
            </div>
          </Form>

        </Col>
      </Row>
    )
}

App.js

import React from 'react';
import { Container} from 'react-bootstrap';
import {BrowserRouter, Route, Routes} from 'react-router-dom';

import ApolloProvider from "./ApolloProvider";

import './App.scss';

import Home from "./pages/Home";
import Register from "./pages/Register";
import Login from "./pages/Login";


function App() {


  return (
    <ApolloProvider>
      <BrowserRouter>
        <Container className="pt-5">
          <Routes>
          <Route  exact path="/" element={<Home />}/>
          <Route path="/register"  element={<Register />} />
          <Route path="/login"  element={<Login />} />
          </Routes>
        </Container>
      </BrowserRouter>
    </ApolloProvider>
  );
}

export default App;

I am able to get the entries in mySQL table, but after register I am not able to redirect to /login.

I am getting the TypeError in console. But I am not sure why I am getting this.

enter image description here

package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@apollo/client": "^3.5.7",
    "@testing-library/jest-dom": "^5.14.1",
    "@testing-library/react": "^12.0.0",
    "@testing-library/user-event": "^13.2.1",
    "bootstrap": "^5.1.3",
    "graphql": "^16.2.0",
    "node-sass": "^7.0.1",
    "react": "^17.0.2",
    "react-bootstrap": "^2.1.0",
    "react-dom": "^17.0.2",
    "react-router-dom": "^6.2.1",
    "react-scripts": "5.0.0",
    "web-vitals": "^2.1.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Using v6 of "react-router-dom".

Remove an array from an Array if a certain value exists in the array in javascript

Trying to remove an entire array if within my data if it contains a certain value.

What would be the best approach to this problem?

data = [['true', 'visiting-today', 'DVM-Wiessman','J-001'],
['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001'],
['false', 'visiting-tommorrow', 'DVM-Kon','J-001']]


var del_value = 'J-001';

function remove_from_list(list) {
    for( var i = 0; i < list.length; i++) { 
        for( var j =0; j < Object.keys(list[i]).length.length; j++) {
            if(del_value == list[i][j]) {
                list.splice(list[i], 1);
            }
        }
    }
    return list;
}

actual output

data = 
[['true', 'visiting-today', 'DVM-Wiessman','J-001'],
['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001'],
['false', 'visiting-tommorrow', 'DVM-Kon','J-001']]

desired result — to remove all arrays that have the value 'J-001'

data = 
[['false', 'visiting-tommorrow', 'DVM-Stevens','K-001'],
['true', 'visiting-tommorrow', 'DVM-Stevens','Z-001']]

Looping a Rock, Paper Scissors game multiple times in Javascript using a function

I am currently working on a simple rock, paper scissor game while using different functions. I want to have the game loop a couple of times, but I get lost in terms of where I add the loop into the function. I’ve seen a few different solutions online, but nothing that fits what I have done so far. Any guidance would be appreciated, thanks!

const computerSelection = computerPlay

function playerSelection() {
    const playerSelection = prompt("Lets play rock, paper, scissors. Which is yours?")

    return playerSelection
}

function computerPlay() {
    const pieces = ['rock', 'paper', 'scissors'];
    const piece = pieces[Math.floor(Math.random() * pieces.length)]
    
    return piece;
}

function playRound(playerSelection, computerSelection) {
    // Rock 
    if (playerSelection == 'rock') {
        if (computerSelection == 'scissors') {
            return 'You win! Rock beats Scissors!'
        } else if (computerSelection == 'paper') {
            return 'You lose! Paper beats rock!'
        } else if (computerSelection == 'rock') {
            return 'Its a tie!'
        }
    }

    // Scissors
    if (playerSelection == 'scissors') {
        if (computerSelection == 'rock') {
            return 'You lose! Rock beats scissors!'
        } else if (computerSelection == 'paper') {
            return 'You win! Scissors beats paper!'
        } else if (computerSelection == 'scissors') {
            return 'Its a tie!'
        }
    }

    // Paper
    if (playerSelection == 'paper') {
        if (computerSelection == 'rock') {
            return 'You win! Paper beats rock!'
        } else if (computerSelection == 'scissors') {
            return 'You lose! Scissors beats paper!'
        } else if (computerSelection == 'paper') {
            return 'Its a tie!'
        }
    }
}

function game(playRound) {
    for (var i = 0; i < 5; i++){
    }
    return playRound
}

console.log(game())
//console.log(playRound(playerSelection(), computerSelection()));