Creating a View-Model for a header bar: A step-by-step guide

I am looking to develop a View-Model for the header bar using WebStorm, TypeScript, and Aurelia. In my directory, I have a file named header-bar.html with the following code:

<template bindable="router">
  <require from="_controls/clock"></require>
  <require from="_controls/language-switcher"></require>
  <header class="header" role="banner">
    <div class="header-wrapper">
      <div class="header-back">
        <a href="##" onClick="history.back(); return false;">
          <img src="dist/images/01_back_32x32.png">
        </a>
      </div>

      <clock class="header-clock"></clock>

      <div class="header-signals">
        <img src="dist/images/01_Meldung_64x64.png" alt="Meldung" onclick="$('#notification-window, #cover').show()">
        <img src="dist/images/01_Wartung_Montage_kreis_64x64.png" alt="Wartung">
        <img src="dist/images/01_Aktoren_Kreis_64x64.png" alt="Aktoren">
        <img src="dist/images/01_Lock_64x64.png" alt="Lock">
        <img src="dist/images/01_Batterie_fixnav_64x64.png" alt="Batterie">

        <language-switcher class="language-switcher"></language-switcher>
      </div>

      <a href="#" class="header-logo">
        <img src="dist/images/fischerlogo300.png" alt="Logo Image">
      </a>

    </div>
  </header>

</template>

Despite having a TypeScript file named header-bar.ts in the same directory with properties like telNumber, hotLineNumber, and emailAddress defined, there seems to be no connection between them. The TypeScript code is as follows:

export class HeaderBar {
  public telNumber: string;
  public hotLineNumber: string;
  public emailAddress: string;
  public constructor() {
    this.telNumber = "+49999999";
    this.hotLineNumber = "01726666";
    this.emailAddress = "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="8cffe9fefae5efe9ccf4f4f4a2e8e9">[email protected]</a>";
  }
}

I need guidance on how to create a proper View-Model for this header bar. Any assistance would be greatly appreciated.

Answer №1

Initially, I removed .html:

<require from="header-bar"></require>

However, that change alone did not suffice. I made adjustments to the header-bar.ts file as detailed below:

import {autoinject} from "aurelia-dependency-injection";
import {Router} from "aurelia-router";
import {bindable} from "aurelia-templating";

@autoinject
export class HeaderBar {
  public key: string;

  @bindable
  public router: Router;

  constructor() {
    this.key = "one";
  }
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

How to determine the return type based on the quantity of arguments passed to a rest parameter function

Is there a way to create an arrow function using rest parameters that can return different types based on the number of arguments passed? For example, I am looking to implement a safeId() function with the following return type variations: safeId() // () ...

Passing the onChange event in React to a nested child component

The code snippet below illustrates a scenario where the user encounters an error: import React from 'react'; import {render} from 'react-dom'; import Form from './form.jsx'; import axios from 'axios'; class App e ...

Material-UI - Switching thumb styles in a range slider

Looking for a way to style two entities differently on the Material-UI Slider? Entity A as a white circle and Entity B as a red circle? While using data-index can work, there's a flaw when sliding. Is there a better approach? if (data-index === 0) { ...

Navigating through Leaflet to reference a .json file

Looking to integrate a .json vector layer into a Leaflet.js map, which can be seen on the GitHub page here, with the source code available here. Here's a condensed version of the file for reference (full version visible on the linked GitHub page). & ...

Encountering a 405 Error While Trying to Detect Location in Angular 7

I encountered an error 405 (Method Not Allowed) when trying to detect the location. Service public fetchWeatherDataByCoordinates(coordinates: ICoordinates): void { console.log("problem here") this.selectedLocationId.next(this.currentCoordinates ...

Having difficulty creating the probot.github app due to an error: The removal of the programmatic API in npm version 8.0.0 causing failure

Currently, I am facing an issue while attempting to set up the probot.github app using the command npx create-probot-app my-first-app which can be found at: . My system is running on the latest node version v19.3.0 with npm version 9.2.0. However, upon exe ...

Unleashing the Power of Google Apps Script Filters

Having some data in a Google Sheet, I am looking to filter it based on specific criteria and return corresponding values from another column. Additionally, I need to count the number of elements in the resulting column. Below is an example of the data: Sa ...

Experiencing a problem with value formatting while attempting to implement tremor for charts in React with Next.js version 13

import { getAuthSession } from "@/lib/auth"; import { db } from "@/lib/db"; import { Card, LineChart, Text, Title } from "@tremor/react"; import Linechart from "./LineChart"; const dollarFormatter = (value: number) ...

What is the best way to retrieve the first item in owl carousel's content?

I need help creating a slider with two sections: top and bottom. My goal is to display the content from the bottom slider on the top slider. I tried adding a class to the first item element, but it didn't work. If anyone knows how to target the first ...

Tips for personalizing Twitter Bootstrap popover concealment animation

Currently, I am interested in creating a unique hide animation for my popover. Instead of directly modifying bootstrap.js, I would like to implement my own custom code. $.fn.popover = function (option) { return this.each(function () { ...

The Angular component fails to refresh after removing an image

After deleting an image, I have been struggling to find a way to update my component instantly without having to refresh the page. Despite trying various methods like using ChangeDetectorRef, I haven't been successful. Any advice on how to achieve thi ...

Issues arise when attempting to delete messages that have already been retrieved

Having trouble removing messages from a specific user without any success: bot.js client.on("message", (message) => { if (message.content === '$deleteuser') { message.channel.fetchMessages({limit: 10}).then(collec ...

Transform the string into a file format, followed by encoding it into base64

Is there a way to take the string const content="<div>How do I <b>convert </b> this string to file?</div>"; and convert it into an HTML file, then ultimately encode it as a base64 string? The method Buffer.from(content).toString(&ap ...

Revealing the Webhook URL to Users

After creating a connector app for Microsoft Teams using the yo teams command with Yeoman Generator, I encountered an issue. Upon examining the code in src\client\msteamsConnector\MsteamsConnectorConfig.tsx, I noticed that the webhook URL w ...

Trying out the Send feature of Gmail API using Postman

Attempting to use the Gmail API for sending emails. Utilizing Postman as a tool to test requests and obtain correct code for web application integration, encountering an error: { "error": { "errors": [ { "domain": "global", ...

Updating state in React is not possible

I am having trouble updating my state (specifically with setCoords). The API request is returning a 200 status code and the elements I need are present: https://i.stack.imgur.com/a8QzN.png Below is the code I am working with: const App = () => { co ...

Managing events inside a JQuery dialog box

Currently, I have successfully implemented a JQuery dialog that allows users to change their password. The functionality works smoothly as the system checks if the two passwords match and if the new password meets the minimum requirements before making an ...

Is there a similar function in PHP to creating an array with a specified number of elements in JavaScript using "new Array(number)"?

While attempting to convert a basic Javascript function into PHP, I encountered a variable declared as var Variable = new Array (13). In PHP, variables are typically declared like this: $variable = array() But what does the "13" in new Array(13) signify? ...

Is it possible that .focus() does not function on a duplicated object?

Greetings to all! I have created a form with rows of input text fields. Users can add as many rows as needed by clicking the 'add row' button. The functionality to clone() for adding rows is working perfectly. In each row, an input field can o ...

Combining data from multiple API calls in a for loop with AngularJS

I'm working with an API that contains pages from 1 to 10 and my goal is to cycle through these page numbers to make the necessary API calls. app.factory('companies', ['$http', function($http) { var i; for (i = 1; i < 11 ...