Angular import class logic for calculating the number of dots and slashes

Dealing with importing files and classes from other files in Angular can be confusing, especially when it comes to using dots and slashes. It's hard to find a clear logic sometimes. Can anyone provide some guidance on this issue?

Answer №1

./

When you see ./ in a file path, it means moving back from the current file.

For example:

https://i.sstatic.net/yY2xb.png

In the image above, I am inside test.component.ts. By using ./, I exited that file and now I am in the test folder.

../

If you encounter ../ in a file path, it indicates moving back from the current folder.

For instance:

https://i.sstatic.net/WfxTW.png

First, I used ./ to exit test.component.ts, then by using ../, I exited the test folder. So, ./../ helped me get out of the test folder completely.

/

When you come across / in a file path, it signifies moving forward.

For example:

After ./../, I will be at the src scope. To directly move into the app folder, add / to the path: ./../app/

Conclusion=>

/ (normal slash) - moving forward

./ (slash with dot prefix) - moving back from the file

../ (slash with double dots prefix) - moving back from the folder

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

The function is not recognized in C# programming language

Whenever I try to trigger functions by clicking buttons, nothing seems to happen and an error message appears in the console. Uncaught ReferenceError: AddressInputSet is not defined at HTMLButtonElement.onclick I'm new to this and could use ...

Angular's NGX Spinner is efficiently blocking the entire page

I'm currently incorporating ngx-spinner into my Angular application, but I'm running into an issue where it's loading on the entire page instead of just a specific area. Below is the code that I'm using: <p> Hello name </p> ...

Angular application experiencing issues with opening snackbar notifications

I'm currently working on a user registration application in Angular. My goal is to notify the user upon successful account creation or if an error occurs. I've been attempting to use a snackbar for this purpose, but it's not working as expec ...

Gather various input files to attach to FormData

Imagine having a scenario where you have the following form. <form id="testForm"> <input type="file" name="uploads[]"><br/> <input type="file" name="uploads[]"><br/> <input type="file" name="uploads[]"><br/> ...

Modify the background of a div and an image

My goal is to add a background to both the image and the div itself, similar to what I've seen on Amazon. However, I'm struggling to achieve this effect where the white background of the image doesn't show when applied onto the div: Image w ...

Transfer all image files from Node.js to the frontend

What is the best way to send all image files from my backend nodejs server folder to my Reactjs client? I have set up a website where users can sign in and upload their files. However, I am facing an issue where only one file is visible on the client side, ...

What is the process for sending an object as an argument?

I've been encountering random issues with certain parts of my code. This object is initialized within an angular controller. this.tData = { 'questions':[], 'typeQuestion':[], 'category':[], 'dName' ...

The directive for accepting only numbers is not functioning in versions of Chrome 49.xx.xx and earlier

I have implemented a directive in Angular 6 to allow only numbers as input for certain fields. The directive code is shown below: import { Directive, ElementRef, HostListener } from '@angular/core'; @Directive({ selector: '[NumbersOnly]& ...

Tips for applying styles with an on-click event in a loop

I have an array of objects (items) that can be incremented with other items, which are displayed by looping through the array. Take a look at the image here: https://i.sstatic.net/AXRGQ.png When I click on an item, I want to highlight it (for example: c ...

JavaScript Function Call Crashes Script

Currently, I am delving into the world of JavaScript by exploring . I find it beneficial to tackle the exercises provided before progressing to the next chapter as a way to practice. After completing chapter 4 and reviewing the exercises found at the end ...

What is the best way to clear and refresh specific query parameters from the current URL?

For instance, my current URL looks like this: http://domain.com/category/health-beauty/?session={%22session_key%22%3A%22df1eca3f79e122bd915651e5-1325102496%22%2C%22uid%22%3A%221325102496%22%2C%22expires%22%3A0%2C%22secret%22%3A%229eb858d1fc7dda2b37be91228 ...

Accordion for controlling the start and stop of the content slider

I have a code snippet below for a Pure CSS content slider in an accordion that I've built. I'm wondering if it's feasible to control the start and stop of the Content Slider when the accordion opens and closes. Currently, the Content Slider ...

Configuring Next-auth CredentialProvider and setting up redirection

I'm feeling a bit lost when it comes to understanding how the credentials provider and redirects work. The documentation mentions that the credentials provider doesn't support a callback and is specifically for OAuth providers, which I understand ...

learn how to implement local storage for a to-do list application using JavaScript

How do I implement the storage property in this code snippet? The current code is not functioning correctly and resets after each page refresh. Please review my code at the following link: https://jsfiddle.net/74qxgonh/ let values = []; // Accessing Form ...

Exploring Methods to Iterate through an Object Utilizing Two Arrays

Attempting to iterate through states passed as props in another component state = { question:[firstQ, secondQ, thirdQ], tag:[[1,2,3],[4,6],[a,b,c,d]] } I aim to display it on the next Componet with a pattern like: FirstQ [tag1] SecondQ ...

The specific error "Argument is not a function, got undefined" in the $broadcast function is exclusive to Angular on Firefox

An Angular error is popping up in Firefox but not in Chrome or IE. The specific error message is: Error: Argument 'myControllerName' is not a function, got undefined. When tracing the stack, it seems to be originating from the $broadcast function ...

Is it possible to pass a value back from an Atlassian Forge resolver to a Vue custom UI component?

I have a custom Atlassian Forge resolver and Vue Custom UI setup import Resolver from '@forge/resolver' const resolver = new Resolver() resolver.define('getIssueKey', ({context}) => { const jiraKey = context.extension.issue.key ...

Bring in all iterable arrays from TypeScript using the import statement

How can TypeScript be used to access multiple classes from different files as an array? Consider the following folder structure: ├── index.ts └── models ├── index.ts ├── image.entity.ts └── user.entity.ts In the ...

How can I transfer the database from my live server to my localhost using php?

I have a large SQL database operating on a live server. Whenever a bug arises, my usual process is to manually export the database from phpmyadmin (by viewing the output text), dropping the localhost database, importing the output dump, and then importing ...

Using a loop to execute Javascript Promise.all()

I am currently facing an issue where I need to make a web API call twice inside a loop, and then wait for the results before pushing them into a larger array as subarrays. The code snippet below illustrates my approach: var latlngPairs = []; function extra ...