@Input() redirectTo: string = "/home";
switch (data.authenticationStatus.value) {
case "SUCCESS":
this.storageSvc.saveTokens(data.tokens);
window.location.href([this.redirectTo]);
break;
@Input() redirectTo: string = "/home";
switch (data.authenticationStatus.value) {
case "SUCCESS":
this.storageSvc.saveTokens(data.tokens);
window.location.href([this.redirectTo]);
break;
Navigating to External Links
To navigate outside of your application, you can simply use vanilla JavaScript like so:
window.location.href = externalUrl;
Navigating Internally within Angular
Within an Angular application, you can utilize the Angular router to move to a different route. You need to import the router from @angular/router
and inject it into your component's constructor.
import { Router } from '@angular/router';
export class MyComponent {
constructor(private router: Router) {
}
@Input() redirectTo: string = "/home"
navigate() {
this.router.navigateByUrl(this.redirectTo);
}
}
If you have a fully formed relative URL, like in this case, you can simply call router.navigateByUrl(url)
. While there are more complex methods for creating navigation instructions, this basic example is intended to introduce you to routing in Angular.
What is the reason for wanting to utilize this feature? Angular operates as a single Page Application framework, meaning that typically you do not navigate to separate html-pages within your project - everything is contained within one expansive webpage. However, by implementing the router, you can create the illusion of multiple pages; it is important to note that ultimately it still relies on your index.html file in the backend...
Whenever I receive data, one set works perfectly while another set does not Data that is functioning properly looks like this data: Array(16) On the other hand, the problematic data appears as follows data: Menu1Items: Array(5) > 0 { .... } etc ...
I'm working on a marketplace app and I need to display a picture and name of a product when someone shares a link. Similar to how social media posts include a picture and title when shared. Can this be achieved using Angular, and if so, what steps do ...
I recently started working with TypeScript. I encountered an issue when attempting to utilize useEffect in TypeScript within a React context, Error: Argument of type '() => () => boolean' is not assignable to parameter of type 'Effec ...
I am currently working on an Angular 6 + Express.JS application and have encountered a problem. When multiple requests are made simultaneously, especially when there are more than 4 requests, all of them sometimes respond with a 404 error or get cancelled. ...
Upon building my Angular app with a Node.js API and deploying it on Heroku, I encountered an error. Despite this, the app runs smoothly with no errors when tested on my local server. Below are the logs from Heroku: C:\Users\PC>heroku logs -a= ...
Creating a dynamic MEAN app requires passing the dbName based on the logged-in user. The steps involved are as follows: The user logs in and is authenticated using a specific auth REST-API. The Angular application receives the user account data, which inc ...
I am currently attempting to create a dynamic menu using a JSON blob in my TypeScript files for an Angular project. For this task, I am utilizing the / component from Angular Material. The structure of my JSON menu is as follows: { id: 0, ...
For my project, I am attempting to incorporate jqWidgets Angular components: import { Component, ViewChild } from '@angular/core'; import 'jqwidgets-framework'; import { jqxTreeComponent } from "jqwidgets-framework/jqwidgets-ts/angula ...
Currently, I am in the process of migrating an AngularJS application to Angular. The older application included jQuery functionalities which I attempted to retain. However, I have encountered an issue with the 'this' element. Upon loading in Ang ...
In my Typescript interface, I have a predefined set of fields like this: export interface Data { date_created: string; stamp: string; } let myData: Data; But now I need to incorporate "dynamic" fields that can be determined only at runtime. This me ...
Utilizing data-driven styling for boundaries in Google Maps Javascript API V3 is a fantastic feature that appears to be compatible with all map types such as terrain, satellite, and hybrid. Nevertheless, I have encountered difficulties in making it visible ...
My current challenge involves connecting to MySQL. I have set the database connection variables in a .env file located in the root directory, and I am initializing the connection in the app.module.ts file. The problem arises when I attempt to create or run ...
During live testing a URL on Google Search Console, I discovered that while Googlebot can render the page, the structured data is missing. The structured data is generated in JavaScript using the following function: insertStructuredData(genDataFn: Function ...
Is there a way to achieve a status of 200 and stop the controller call if a certain key in the request payload meets my criteria? I've implemented Interceptors in my application, but I'm struggling to send a status of "200" without causing an ex ...
Currently, I am delving into the realm of Angular UI Router in order to effectively manage different sections of my application. If you'd like, check out this plunkr (http://plnkr.co/edit/KH7lgNOG7iCAEDS2D3C1?p=preview) Here are some issues that I&a ...
My Angular 2 application has been throwing an error message stating "Error: Error in ./SampleComponent class SampleComponent - inline template caused by: Variable undefined in strict mode". Strangely, this error only occurs in IE 10. <input type="text" ...
Within my Angular 6 application, I am facing an issue with a variable named "permittedPefs" that is assigned a value after an asynchronous HTTP call. @Injectable() export class FeaturesLoadPermissionsService { permittedPefs = []; constructor() { ...
Split into two separate functions: public valJson(json, schemaFile: string) { return new Promise((resolve, reject) => { this.http.get(schemaFile) .toPromise() .then(fileContents => fileContents.json()) ...
When attempting to deploy my API on Vercel, I consistently encounter the same issue. The problem arises when: https://i.sstatic.net/6JjUJ.png I am using Node, Express, and Typescript. My project consists of a dist folder, as well as an initial src directo ...
I have a Maths class that allows me to alter the operation type. export class Maths { private static _instance: Maths = new Maths(); type: string = "ADD"; constructor() { Maths._instance = this; } public static getInstance(): Maths { ...