angular 6: A class declaration without the 'default' modifier must have a name [closed]












-1














I am getting this kind of error in my ts.file, what could be the reason in which I am just starting to learn the angular/ionic world.





I have tried various ways to clear it but no luck.



import { Component } from '@angular/core';
import { NavController, NavParams } from '@ionic/angular';
import {Announcements} from '../../../environments/environment';
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase} from 'angularfire2/database';
import { take } from 'rxjs/operators';
import { Directive, HostListener, ElementRef } from '@angular/core';

@Component({
selector: 'app-add-our-announcements',
templateUrl: './add-our-announcements.page.html',
styleUrls: ['./add-our-announcements.page.scss'],
})
@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})
export class {

constructor(
private afauth: AngularFireAuth,
private afDatabase: AngularFireDatabase,
public navCtrl: NavController,
public navParams: NavParams,
public element: ElementRef) {
}

announcements = {} as Announcements;

@HostListener('document:keydown.enter', ['$event']) onKeydownHandler() {
this.adjust();
}

AfterViewInit() {
this.adjust();
}

adjust(): void {
const textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
textArea.style.overflow = 'hidden';
textArea.style.height = 'auto';
textArea.style.height = (textArea.scrollHeight + 42) + 'px';
}



createAnnouncements() {
this.afauth.authState.pipe(take(1)).subscribe(() => {
this.afDatabase.list(`announcements`).push(this.announcements)
.then(() => this.navCtrl.navigateForward('ListOfOurAnnouncementsPage'));
});
}

}









share|improve this question















closed as off-topic by Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity Nov 21 '18 at 17:37


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    provide a name for your class as the error suggests. export class MyClassNameHere
    – Richard Hubley
    Nov 21 '18 at 14:49










  • am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:07
















-1














I am getting this kind of error in my ts.file, what could be the reason in which I am just starting to learn the angular/ionic world.





I have tried various ways to clear it but no luck.



import { Component } from '@angular/core';
import { NavController, NavParams } from '@ionic/angular';
import {Announcements} from '../../../environments/environment';
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase} from 'angularfire2/database';
import { take } from 'rxjs/operators';
import { Directive, HostListener, ElementRef } from '@angular/core';

@Component({
selector: 'app-add-our-announcements',
templateUrl: './add-our-announcements.page.html',
styleUrls: ['./add-our-announcements.page.scss'],
})
@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})
export class {

constructor(
private afauth: AngularFireAuth,
private afDatabase: AngularFireDatabase,
public navCtrl: NavController,
public navParams: NavParams,
public element: ElementRef) {
}

announcements = {} as Announcements;

@HostListener('document:keydown.enter', ['$event']) onKeydownHandler() {
this.adjust();
}

AfterViewInit() {
this.adjust();
}

adjust(): void {
const textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
textArea.style.overflow = 'hidden';
textArea.style.height = 'auto';
textArea.style.height = (textArea.scrollHeight + 42) + 'px';
}



createAnnouncements() {
this.afauth.authState.pipe(take(1)).subscribe(() => {
this.afDatabase.list(`announcements`).push(this.announcements)
.then(() => this.navCtrl.navigateForward('ListOfOurAnnouncementsPage'));
});
}

}









share|improve this question















closed as off-topic by Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity Nov 21 '18 at 17:37


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.









  • 4




    provide a name for your class as the error suggests. export class MyClassNameHere
    – Richard Hubley
    Nov 21 '18 at 14:49










  • am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:07














-1












-1








-1







I am getting this kind of error in my ts.file, what could be the reason in which I am just starting to learn the angular/ionic world.





I have tried various ways to clear it but no luck.



import { Component } from '@angular/core';
import { NavController, NavParams } from '@ionic/angular';
import {Announcements} from '../../../environments/environment';
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase} from 'angularfire2/database';
import { take } from 'rxjs/operators';
import { Directive, HostListener, ElementRef } from '@angular/core';

@Component({
selector: 'app-add-our-announcements',
templateUrl: './add-our-announcements.page.html',
styleUrls: ['./add-our-announcements.page.scss'],
})
@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})
export class {

constructor(
private afauth: AngularFireAuth,
private afDatabase: AngularFireDatabase,
public navCtrl: NavController,
public navParams: NavParams,
public element: ElementRef) {
}

announcements = {} as Announcements;

@HostListener('document:keydown.enter', ['$event']) onKeydownHandler() {
this.adjust();
}

AfterViewInit() {
this.adjust();
}

adjust(): void {
const textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
textArea.style.overflow = 'hidden';
textArea.style.height = 'auto';
textArea.style.height = (textArea.scrollHeight + 42) + 'px';
}



createAnnouncements() {
this.afauth.authState.pipe(take(1)).subscribe(() => {
this.afDatabase.list(`announcements`).push(this.announcements)
.then(() => this.navCtrl.navigateForward('ListOfOurAnnouncementsPage'));
});
}

}









share|improve this question















I am getting this kind of error in my ts.file, what could be the reason in which I am just starting to learn the angular/ionic world.





I have tried various ways to clear it but no luck.



import { Component } from '@angular/core';
import { NavController, NavParams } from '@ionic/angular';
import {Announcements} from '../../../environments/environment';
import {AngularFireAuth} from 'angularfire2/auth';
import {AngularFireDatabase} from 'angularfire2/database';
import { take } from 'rxjs/operators';
import { Directive, HostListener, ElementRef } from '@angular/core';

@Component({
selector: 'app-add-our-announcements',
templateUrl: './add-our-announcements.page.html',
styleUrls: ['./add-our-announcements.page.scss'],
})
@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})
export class {

constructor(
private afauth: AngularFireAuth,
private afDatabase: AngularFireDatabase,
public navCtrl: NavController,
public navParams: NavParams,
public element: ElementRef) {
}

announcements = {} as Announcements;

@HostListener('document:keydown.enter', ['$event']) onKeydownHandler() {
this.adjust();
}

AfterViewInit() {
this.adjust();
}

adjust(): void {
const textArea = this.element.nativeElement.getElementsByTagName('textarea')[0];
textArea.style.overflow = 'hidden';
textArea.style.height = 'auto';
textArea.style.height = (textArea.scrollHeight + 42) + 'px';
}



createAnnouncements() {
this.afauth.authState.pipe(take(1)).subscribe(() => {
this.afDatabase.list(`announcements`).push(this.announcements)
.then(() => this.navCtrl.navigateForward('ListOfOurAnnouncementsPage'));
});
}

}






angular typescript ionic-framework angular6






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 '18 at 14:46









Aleksey Solovey

3,5293726




3,5293726










asked Nov 21 '18 at 14:45









James Macharia

83




83




closed as off-topic by Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity Nov 21 '18 at 17:37


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.




closed as off-topic by Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity Nov 21 '18 at 17:37


This question appears to be off-topic. The users who voted to close gave this specific reason:


  • "This question was caused by a problem that can no longer be reproduced or a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers. This can often be avoided by identifying and closely inspecting the shortest program necessary to reproduce the problem before posting." – Suraj Rao, eyllanesc, sideshowbarker, Vega, Machavity

If this question can be reworded to fit the rules in the help center, please edit the question.








  • 4




    provide a name for your class as the error suggests. export class MyClassNameHere
    – Richard Hubley
    Nov 21 '18 at 14:49










  • am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:07














  • 4




    provide a name for your class as the error suggests. export class MyClassNameHere
    – Richard Hubley
    Nov 21 '18 at 14:49










  • am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:07








4




4




provide a name for your class as the error suggests. export class MyClassNameHere
– Richard Hubley
Nov 21 '18 at 14:49




provide a name for your class as the error suggests. export class MyClassNameHere
– Richard Hubley
Nov 21 '18 at 14:49












am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
– James Macharia
Nov 21 '18 at 15:07




am now getting this kind of error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
– James Macharia
Nov 21 '18 at 15:07












1 Answer
1






active

oldest

votes


















1














Your class doesn't have a name.
Ex:



@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})


export class TextAreaDirective {

constructor() {
}


Please look at how classes are defined in Typescript:



Also look at Angular style guide for coding norms.




Do use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is feature.type.ts.



Do use conventional type names including .service, .component, .pipe,
.module, and .directive.
Invent additional type names if you must but
take care not to create too many.



Why? Type names provide a consistent way to quickly identify what is
in the file.



Why? Type names make it easy to find a specific file type using an
editor or IDE's fuzzy search techniques.



Why? Unabbreviated type names such as .service are descriptive and
unambiguous. Abbreviations such as .srv, .svc, and .serv can be
confusing.







share|improve this answer





















  • thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:17












  • Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
    – nircraft
    Nov 21 '18 at 15:23












  • yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
    – James Macharia
    Nov 21 '18 at 15:29










  • Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
    – nircraft
    Nov 21 '18 at 15:33












  • thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
    – James Macharia
    Nov 21 '18 at 15:42


















1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









1














Your class doesn't have a name.
Ex:



@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})


export class TextAreaDirective {

constructor() {
}


Please look at how classes are defined in Typescript:



Also look at Angular style guide for coding norms.




Do use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is feature.type.ts.



Do use conventional type names including .service, .component, .pipe,
.module, and .directive.
Invent additional type names if you must but
take care not to create too many.



Why? Type names provide a consistent way to quickly identify what is
in the file.



Why? Type names make it easy to find a specific file type using an
editor or IDE's fuzzy search techniques.



Why? Unabbreviated type names such as .service are descriptive and
unambiguous. Abbreviations such as .srv, .svc, and .serv can be
confusing.







share|improve this answer





















  • thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:17












  • Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
    – nircraft
    Nov 21 '18 at 15:23












  • yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
    – James Macharia
    Nov 21 '18 at 15:29










  • Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
    – nircraft
    Nov 21 '18 at 15:33












  • thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
    – James Macharia
    Nov 21 '18 at 15:42
















1














Your class doesn't have a name.
Ex:



@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})


export class TextAreaDirective {

constructor() {
}


Please look at how classes are defined in Typescript:



Also look at Angular style guide for coding norms.




Do use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is feature.type.ts.



Do use conventional type names including .service, .component, .pipe,
.module, and .directive.
Invent additional type names if you must but
take care not to create too many.



Why? Type names provide a consistent way to quickly identify what is
in the file.



Why? Type names make it easy to find a specific file type using an
editor or IDE's fuzzy search techniques.



Why? Unabbreviated type names such as .service are descriptive and
unambiguous. Abbreviations such as .srv, .svc, and .serv can be
confusing.







share|improve this answer





















  • thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:17












  • Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
    – nircraft
    Nov 21 '18 at 15:23












  • yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
    – James Macharia
    Nov 21 '18 at 15:29










  • Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
    – nircraft
    Nov 21 '18 at 15:33












  • thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
    – James Macharia
    Nov 21 '18 at 15:42














1












1








1






Your class doesn't have a name.
Ex:



@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})


export class TextAreaDirective {

constructor() {
}


Please look at how classes are defined in Typescript:



Also look at Angular style guide for coding norms.




Do use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is feature.type.ts.



Do use conventional type names including .service, .component, .pipe,
.module, and .directive.
Invent additional type names if you must but
take care not to create too many.



Why? Type names provide a consistent way to quickly identify what is
in the file.



Why? Type names make it easy to find a specific file type using an
editor or IDE's fuzzy search techniques.



Why? Unabbreviated type names such as .service are descriptive and
unambiguous. Abbreviations such as .srv, .svc, and .serv can be
confusing.







share|improve this answer












Your class doesn't have a name.
Ex:



@Directive({
selector: 'ion-textarea[autosize]' // Attribute selector,
})


export class TextAreaDirective {

constructor() {
}


Please look at how classes are defined in Typescript:



Also look at Angular style guide for coding norms.




Do use consistent type names for all components following a pattern that describes the component's feature then its type. A recommended pattern is feature.type.ts.



Do use conventional type names including .service, .component, .pipe,
.module, and .directive.
Invent additional type names if you must but
take care not to create too many.



Why? Type names provide a consistent way to quickly identify what is
in the file.



Why? Type names make it easy to find a specific file type using an
editor or IDE's fuzzy search techniques.



Why? Unabbreviated type names such as .service are descriptive and
unambiguous. Abbreviations such as .srv, .svc, and .serv can be
confusing.








share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 21 '18 at 15:13









nircraft

1,148118




1,148118












  • thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:17












  • Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
    – nircraft
    Nov 21 '18 at 15:23












  • yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
    – James Macharia
    Nov 21 '18 at 15:29










  • Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
    – nircraft
    Nov 21 '18 at 15:33












  • thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
    – James Macharia
    Nov 21 '18 at 15:42


















  • thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
    – James Macharia
    Nov 21 '18 at 15:17












  • Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
    – nircraft
    Nov 21 '18 at 15:23












  • yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
    – James Macharia
    Nov 21 '18 at 15:29










  • Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
    – nircraft
    Nov 21 '18 at 15:33












  • thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
    – James Macharia
    Nov 21 '18 at 15:42
















thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
– James Macharia
Nov 21 '18 at 15:17






thank you, i just added a name into the class, and now it has brought and error "The name of the class AddOurAnnouncementsPage should end with the suffix Directive"
– James Macharia
Nov 21 '18 at 15:17














Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
– nircraft
Nov 21 '18 at 15:23






Yes your class name should have Directive attached to it. Normally your class name should end with the type of class. For ex: a component class should have a name: MyButtonComponent , A directive should be AddOurAnnouncementsDirective and so on.
– nircraft
Nov 21 '18 at 15:23














yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
– James Macharia
Nov 21 '18 at 15:29




yes i just added the directive to the name, now its alerting me "The selector of the directive "AddOurAnnouncementsPageDirective" should have prefix "app" "
– James Macharia
Nov 21 '18 at 15:29












Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
– nircraft
Nov 21 '18 at 15:33






Yes, These are your ts-lint rules defined in tslint.json. You can add "app" to selector EX: selector: 'app-ion-textarea[autosize]' or chose to disable the same by removing or modifying this rule in the tslint.json. It's a standard to have directive selectors use app, you can add any other value to it as well. For Ex: "directive-selector": [ true, "attribute", ["myapp", "myname"], "camelCase" ], "component-selector": [ true, "element", ["myapp", "myname"], "kebab-case" ],
– nircraft
Nov 21 '18 at 15:33














thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
– James Macharia
Nov 21 '18 at 15:42




thank you for the continuos feedback nkuma_12, i have tried both and no change to the error
– James Macharia
Nov 21 '18 at 15:42



Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

TypeError: fit_transform() missing 1 required positional argument: 'X'