Do I have to use a string for lazyloading


#1

So my buddy told me it’s a bad design that I’m using “mypage” as a string, if someone else renamed the actual mypage file, the app would break.

Is “mypage” as string the only way to maintain lazy loading

this.nav.push("mypage");

#2

Same thing for *ngFor he told me the way that I write those code are bad and easy to break …anyone?

*ngFor="let result of results"

#3

nav.push(‘MyPage’) is necessary when referencing lazy loaded pages. Without strings, you’d have to add that page to app.module.ts to import the reference which would throw an error because the page would now be in 2 modules. He’s wrong.

If he doesn’t want strings around it, the only solution is to make the page not a lazy loaded page. I’d use single quotes when referencing pages. It will put him at ease to a degree.

Also, you’re referencing the component, not the file. I don’t think renaming the file renames the component. Though, honestly, ive never renamed a file so take that with a grain of salt.

“let result of results” is how Ionic works. He’s wrong.

He may have a background that does not include Ionic and in my experience, many devs, and it’s not irrational, believe things don’t like to be put in quotes.

Ionic is different.


#4

Thanks for your insightful reply, Jay :slightly_smiling_face:


#5

No problem. I went through a similar situation with someone I was developing for. It was beyond frustrating.