Angular Directives js2

Asked

Viewed 22 times

0

import { Component } from '@angular/core';
import { AuthDirective } from '../utils/auth.directive';
import { Router } from '@angular/router';
import { HttpClientService } from '../utils/http-client.service';
import { BaseAddressService } from '../utils/base-address.service';
import { AuthService, ClienteLogado } from '../utils/auth.service';
import {ModalUtilComponent} from '../utils/modal-util-component';

@Component({
templateUrl: './carrinho.component.html',
directives: [ Router, ModalUtilComponent ],

})

Personal qnd I will run the Component that has as function to return a modal, it is not accepting my directive and this returning the following error.

/src/app/carrinho/carrinho.component.ts (11,5): Argument of type '{ templateUrl: string; directives: typeof ModalUtilComponent[]; }' is not assignable to parameter of type 'Component'.
  Object literal may only specify known properties, and 'directives' does not exist in type 'Component'. 

What could be wrong ?

thanks in advance !

1 answer

0

In the latest versions of Angular, you no longer set Directives in @Component.

Now you declare your directives in your @ngModule. For example:

@NgModule({
  declarations: [
    AppComponent,
    HeaderComponent,
    ModalUtilComponent
  ]
})

Another thing, I don’t know what exactly you’re trying to do, but the Router is not a directive, but a service that needs to be injected into your directive, just take a look here.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.