Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Expected the operants to be of similar type or any Angular

I got this issue where i cannot find the solutionenter image description here

As I saw router: Router and router.url: string. So I can't find any explanation why it's complaining in html when router.url === '/successlogin'. Any idea?

Update: I changed type of router, router.url: String and it's ok now but I think it should work the opposite. Why is this happening? Until now I thought type string was the "right" one and not String...

My code simplified:

HTML

<div *ngIf="!global.showUnauthorizedMessage || router.url === '/successlogin'" class="beforeFooter"></div>
 <div *ngIf="!global.showUnauthorizedMessage || router.url ==='/successlogin'" id="footer">

Component

import { Router } from '@angular/router';
constructor( public router: Router) { code here }
like image 422
TheodoreTsg Avatar asked Jun 07 '19 14:06

TheodoreTsg


1 Answers

This message is from the "Angular Language Service" extension in VSCode !

Probably an update because before I didn't have this message....

2 solutions I found is to use localeCompare() like this:

router.url.localeCompare('/successLogin')===0

or

use String instead of string

like image 131
A. Morel Avatar answered Nov 15 '22 20:11

A. Morel