TypeError: Cannot read property 'toUpperCase' of undefined











up vote
1
down vote

favorite












I have tried using custom pipe.This is my pipe file



import { Pipe, PipeTransform } from '@angular/core';
import { User } from 'src/app/user';
import { ApiService } from 'src/app/api.service';
import { Observable } from 'rxjs';
import { isNgTemplate } from '@angular/compiler';
import { map } from 'rxjs/operators';

@Pipe({
name: 'my-pipe'

})
export class MyPipePipe implements PipeTransform {
isEqual = false;
api: ApiService;

transform(post_id: number, users: Observable< User> ): any {
// users = this.api.getUserList();
users.subscribe(user => user.filter(userss => {
if (userss.id === post_id && post_id !== null) { this.isEqual = true; } else {
console.log(this.isEqual + ' ' + ' hataa');
}
}));

}


All i want is nonexistent users cant post.Therefore i trying user's id equalize with post's userId.Here is my html code



    <div class="form-group">
<label for="userId">User Id</label>
<input type="number" class="form-control" id ="userId" name="userId" required [(ngModel)]="posts.userId">
<!--<div class="tetx text-danger" *ngIf="!isEqual" >Invalid Id!!!</div>-->
<div *ngIf=" my-pipe: posts.userId " >

Invalidd


</div>

</div>


But unfortunately I get this error:




[Angular] TypeError: Cannot read property 'toUpperCase' of undefined











share|improve this question




















  • 7




    Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
    – SiddAjmera
    Nov 19 at 10:50










  • <div *ngFor="let u of users_s | my-pipe " > i got error in this line
    – cmyldz
    Nov 19 at 10:58










  • Please poste your full stack trace. As text, not as image.
    – trichetriche
    Nov 19 at 11:04










  • @trichetriche i posted like this with intent to being more understandable
    – cmyldz
    Nov 19 at 11:14










  • @trichetriche but if necessary; i can poste all my code
    – cmyldz
    Nov 19 at 11:15















up vote
1
down vote

favorite












I have tried using custom pipe.This is my pipe file



import { Pipe, PipeTransform } from '@angular/core';
import { User } from 'src/app/user';
import { ApiService } from 'src/app/api.service';
import { Observable } from 'rxjs';
import { isNgTemplate } from '@angular/compiler';
import { map } from 'rxjs/operators';

@Pipe({
name: 'my-pipe'

})
export class MyPipePipe implements PipeTransform {
isEqual = false;
api: ApiService;

transform(post_id: number, users: Observable< User> ): any {
// users = this.api.getUserList();
users.subscribe(user => user.filter(userss => {
if (userss.id === post_id && post_id !== null) { this.isEqual = true; } else {
console.log(this.isEqual + ' ' + ' hataa');
}
}));

}


All i want is nonexistent users cant post.Therefore i trying user's id equalize with post's userId.Here is my html code



    <div class="form-group">
<label for="userId">User Id</label>
<input type="number" class="form-control" id ="userId" name="userId" required [(ngModel)]="posts.userId">
<!--<div class="tetx text-danger" *ngIf="!isEqual" >Invalid Id!!!</div>-->
<div *ngIf=" my-pipe: posts.userId " >

Invalidd


</div>

</div>


But unfortunately I get this error:




[Angular] TypeError: Cannot read property 'toUpperCase' of undefined











share|improve this question




















  • 7




    Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
    – SiddAjmera
    Nov 19 at 10:50










  • <div *ngFor="let u of users_s | my-pipe " > i got error in this line
    – cmyldz
    Nov 19 at 10:58










  • Please poste your full stack trace. As text, not as image.
    – trichetriche
    Nov 19 at 11:04










  • @trichetriche i posted like this with intent to being more understandable
    – cmyldz
    Nov 19 at 11:14










  • @trichetriche but if necessary; i can poste all my code
    – cmyldz
    Nov 19 at 11:15













up vote
1
down vote

favorite









up vote
1
down vote

favorite











I have tried using custom pipe.This is my pipe file



import { Pipe, PipeTransform } from '@angular/core';
import { User } from 'src/app/user';
import { ApiService } from 'src/app/api.service';
import { Observable } from 'rxjs';
import { isNgTemplate } from '@angular/compiler';
import { map } from 'rxjs/operators';

@Pipe({
name: 'my-pipe'

})
export class MyPipePipe implements PipeTransform {
isEqual = false;
api: ApiService;

transform(post_id: number, users: Observable< User> ): any {
// users = this.api.getUserList();
users.subscribe(user => user.filter(userss => {
if (userss.id === post_id && post_id !== null) { this.isEqual = true; } else {
console.log(this.isEqual + ' ' + ' hataa');
}
}));

}


All i want is nonexistent users cant post.Therefore i trying user's id equalize with post's userId.Here is my html code



    <div class="form-group">
<label for="userId">User Id</label>
<input type="number" class="form-control" id ="userId" name="userId" required [(ngModel)]="posts.userId">
<!--<div class="tetx text-danger" *ngIf="!isEqual" >Invalid Id!!!</div>-->
<div *ngIf=" my-pipe: posts.userId " >

Invalidd


</div>

</div>


But unfortunately I get this error:




[Angular] TypeError: Cannot read property 'toUpperCase' of undefined











share|improve this question















I have tried using custom pipe.This is my pipe file



import { Pipe, PipeTransform } from '@angular/core';
import { User } from 'src/app/user';
import { ApiService } from 'src/app/api.service';
import { Observable } from 'rxjs';
import { isNgTemplate } from '@angular/compiler';
import { map } from 'rxjs/operators';

@Pipe({
name: 'my-pipe'

})
export class MyPipePipe implements PipeTransform {
isEqual = false;
api: ApiService;

transform(post_id: number, users: Observable< User> ): any {
// users = this.api.getUserList();
users.subscribe(user => user.filter(userss => {
if (userss.id === post_id && post_id !== null) { this.isEqual = true; } else {
console.log(this.isEqual + ' ' + ' hataa');
}
}));

}


All i want is nonexistent users cant post.Therefore i trying user's id equalize with post's userId.Here is my html code



    <div class="form-group">
<label for="userId">User Id</label>
<input type="number" class="form-control" id ="userId" name="userId" required [(ngModel)]="posts.userId">
<!--<div class="tetx text-danger" *ngIf="!isEqual" >Invalid Id!!!</div>-->
<div *ngIf=" my-pipe: posts.userId " >

Invalidd


</div>

</div>


But unfortunately I get this error:




[Angular] TypeError: Cannot read property 'toUpperCase' of undefined








angular angular6 angular-forms angular-pipe






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 11:56









Uwe Keim

27.3k30128210




27.3k30128210










asked Nov 19 at 10:48









cmyldz

64




64








  • 7




    Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
    – SiddAjmera
    Nov 19 at 10:50










  • <div *ngFor="let u of users_s | my-pipe " > i got error in this line
    – cmyldz
    Nov 19 at 10:58










  • Please poste your full stack trace. As text, not as image.
    – trichetriche
    Nov 19 at 11:04










  • @trichetriche i posted like this with intent to being more understandable
    – cmyldz
    Nov 19 at 11:14










  • @trichetriche but if necessary; i can poste all my code
    – cmyldz
    Nov 19 at 11:15














  • 7




    Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
    – SiddAjmera
    Nov 19 at 10:50










  • <div *ngFor="let u of users_s | my-pipe " > i got error in this line
    – cmyldz
    Nov 19 at 10:58










  • Please poste your full stack trace. As text, not as image.
    – trichetriche
    Nov 19 at 11:04










  • @trichetriche i posted like this with intent to being more understandable
    – cmyldz
    Nov 19 at 11:14










  • @trichetriche but if necessary; i can poste all my code
    – cmyldz
    Nov 19 at 11:15








7




7




Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
– SiddAjmera
Nov 19 at 10:50




Your code has no signs of it having toUpperCase in there. Where exactly are you using it?
– SiddAjmera
Nov 19 at 10:50












<div *ngFor="let u of users_s | my-pipe " > i got error in this line
– cmyldz
Nov 19 at 10:58




<div *ngFor="let u of users_s | my-pipe " > i got error in this line
– cmyldz
Nov 19 at 10:58












Please poste your full stack trace. As text, not as image.
– trichetriche
Nov 19 at 11:04




Please poste your full stack trace. As text, not as image.
– trichetriche
Nov 19 at 11:04












@trichetriche i posted like this with intent to being more understandable
– cmyldz
Nov 19 at 11:14




@trichetriche i posted like this with intent to being more understandable
– cmyldz
Nov 19 at 11:14












@trichetriche but if necessary; i can poste all my code
– cmyldz
Nov 19 at 11:15




@trichetriche but if necessary; i can poste all my code
– cmyldz
Nov 19 at 11:15












1 Answer
1






active

oldest

votes

















up vote
1
down vote













The error comes from Angular compiler that tries to compile your template.



Choose another name for your pipe, i.e. myPipe:



@Pipe({
name: 'myPipe'


...



*ngFor="let u of users_s | myPipe"


And you can't use pipe without passing value to it:



*ngIf=" my-pipe: posts.userId "


it should be something:



*ngIf="postId | myPipe"





share|improve this answer























  • I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
    – cmyldz
    Nov 19 at 11:56










  • @Pipe({ name: 'myPipe'
    – yurzui
    Nov 19 at 11:57










  • Yes ; I changed like you said
    – cmyldz
    Nov 19 at 11:58










  • Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
    – yurzui
    Nov 19 at 11:59












  • red line appears under the myPipe
    – cmyldz
    Nov 19 at 12:08











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372987%2ftypeerror-cannot-read-property-touppercase-of-undefined%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
1
down vote













The error comes from Angular compiler that tries to compile your template.



Choose another name for your pipe, i.e. myPipe:



@Pipe({
name: 'myPipe'


...



*ngFor="let u of users_s | myPipe"


And you can't use pipe without passing value to it:



*ngIf=" my-pipe: posts.userId "


it should be something:



*ngIf="postId | myPipe"





share|improve this answer























  • I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
    – cmyldz
    Nov 19 at 11:56










  • @Pipe({ name: 'myPipe'
    – yurzui
    Nov 19 at 11:57










  • Yes ; I changed like you said
    – cmyldz
    Nov 19 at 11:58










  • Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
    – yurzui
    Nov 19 at 11:59












  • red line appears under the myPipe
    – cmyldz
    Nov 19 at 12:08















up vote
1
down vote













The error comes from Angular compiler that tries to compile your template.



Choose another name for your pipe, i.e. myPipe:



@Pipe({
name: 'myPipe'


...



*ngFor="let u of users_s | myPipe"


And you can't use pipe without passing value to it:



*ngIf=" my-pipe: posts.userId "


it should be something:



*ngIf="postId | myPipe"





share|improve this answer























  • I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
    – cmyldz
    Nov 19 at 11:56










  • @Pipe({ name: 'myPipe'
    – yurzui
    Nov 19 at 11:57










  • Yes ; I changed like you said
    – cmyldz
    Nov 19 at 11:58










  • Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
    – yurzui
    Nov 19 at 11:59












  • red line appears under the myPipe
    – cmyldz
    Nov 19 at 12:08













up vote
1
down vote










up vote
1
down vote









The error comes from Angular compiler that tries to compile your template.



Choose another name for your pipe, i.e. myPipe:



@Pipe({
name: 'myPipe'


...



*ngFor="let u of users_s | myPipe"


And you can't use pipe without passing value to it:



*ngIf=" my-pipe: posts.userId "


it should be something:



*ngIf="postId | myPipe"





share|improve this answer














The error comes from Angular compiler that tries to compile your template.



Choose another name for your pipe, i.e. myPipe:



@Pipe({
name: 'myPipe'


...



*ngFor="let u of users_s | myPipe"


And you can't use pipe without passing value to it:



*ngIf=" my-pipe: posts.userId "


it should be something:



*ngIf="postId | myPipe"






share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 at 12:11

























answered Nov 19 at 11:52









yurzui

91.8k10180204




91.8k10180204












  • I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
    – cmyldz
    Nov 19 at 11:56










  • @Pipe({ name: 'myPipe'
    – yurzui
    Nov 19 at 11:57










  • Yes ; I changed like you said
    – cmyldz
    Nov 19 at 11:58










  • Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
    – yurzui
    Nov 19 at 11:59












  • red line appears under the myPipe
    – cmyldz
    Nov 19 at 12:08


















  • I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
    – cmyldz
    Nov 19 at 11:56










  • @Pipe({ name: 'myPipe'
    – yurzui
    Nov 19 at 11:57










  • Yes ; I changed like you said
    – cmyldz
    Nov 19 at 11:58










  • Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
    – yurzui
    Nov 19 at 11:59












  • red line appears under the myPipe
    – cmyldz
    Nov 19 at 12:08
















I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
– cmyldz
Nov 19 at 11:56




I got this error >> [Angular] Identifier 'myPipe' is not defined. The component declaration, template variable declarations, and element references do not contain such a member
– cmyldz
Nov 19 at 11:56












@Pipe({ name: 'myPipe'
– yurzui
Nov 19 at 11:57




@Pipe({ name: 'myPipe'
– yurzui
Nov 19 at 11:57












Yes ; I changed like you said
– cmyldz
Nov 19 at 11:58




Yes ; I changed like you said
– cmyldz
Nov 19 at 11:58












Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
– yurzui
Nov 19 at 11:59






Is it Angular language service error? Try to reopen your editor. Do you have any runtime errors?
– yurzui
Nov 19 at 11:59














red line appears under the myPipe
– cmyldz
Nov 19 at 12:08




red line appears under the myPipe
– cmyldz
Nov 19 at 12:08


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53372987%2ftypeerror-cannot-read-property-touppercase-of-undefined%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Costa Masnaga

Fotorealismo

Sidney Franklin