my ionic info:
@ionic/cli-utils : 1.4.0
Cordova CLI : 7.0.1
Ionic CLI : 3.4.0
The issue is that I created a directive with the ionic cli which automatically updates my app.modules.ts, but i tried in several ways and the directive doesn’t work,
this is my app.modules.ts
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { HttpModule } from '@angular/http';
import { MyApp } from './app.component';
import { HighlightDirective } from '../directives/highlight/highlight';
@NgModule({
declarations: [
MyApp,
HighlightDirective
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp),
HttpModule
],
bootstrap: [IonicApp],
entryComponents: [
MyApp
],
providers: [
//native providers
]
})
export class AppModule {}
this is highlight.ts
import { Directive, ElementRef } from '@angular/core';
/**
* Generated class for the HighlightDirective directive.
*
* See https://angular.io/docs/ts/latest/api/core/index/DirectiveMetadata-class.html
* for more info on Angular Directives.
*/
@Directive({
selector: '[highlight]' // Attribute selector
})
export class HighlightDirective {
constructor(el: ElementRef) {
console.log("Directive initialized");
el.nativeElement.style.backgroundColor = 'yellow';
}
}
and in the page i’m using the directive its the following
<ion-header>
<ion-navbar>
<ion-title>New Page</ion-title>
</ion-navbar>
</ion-header>
<ion-content padding>
<div highlight>
Hi
</div>
</ion-content>
the page.ts
@IonicPage()
@Component({
selector: 'page-new-client',
templateUrl: 'new-client.html',
})
export class NewClientPage {
constructor(public navCtrl: NavController, public navParams: NavParams) {
}
ionViewDidLoad() {
}
}
but when I load the page that tries to use the directive, i get nothing
and this is my console:
I’m using Lazy loading for Page navigation, any help will be appreciated