aldoso
December 9, 2017, 5:22pm
1
Hi guys! I have a problem which is pretty tricky, so please help me out
I have this item.number
I want to bind item.number as an interpolation in an Ionic CSS selector named page1
so, to use it in another .html file, I want to transform <page1></page1>
to be: <page{{item.number}}></page{{item.number}}>
Unfortunately this does not work, so whatâs the workaround? Thanks!
Iâm fairly certain that the desired functionality is impossible. Angular just doesnât really work that way.
Iâm really confused as to what the use case would be here, so would it be possible for you to explain what you want in a larger sense so that perhaps we can come up with a different route?
aldoso
December 9, 2017, 5:51pm
3
Thanks Sigmund,
I have this also explained here: Html content inside an object value
Here also I wanna achieve the same thing basically
I hope it makes sense
aldoso
December 9, 2017, 6:31pm
4
I made a simple schema explaining my need:
A simple list with the buttons and a string pointing to a page being lazy loaded pushed on rhe stack seems to come closest to what ypu want, imho
And no, i am not going give u code
aldoso
December 9, 2017, 7:00pm
6
thanks, I will investigate what that is and how that works
aldoso
December 10, 2017, 2:07am
7
I have tried lazyloading as in this tutorial: https://www.youtube.com/watch?v=h4qrhJFeudA
but I cannot understand why interpolation doesnât work not even now Please help
and here is the error:
Interpolation doesnât work in TypeScript/JavaScript.
Youâd instead do the Irish tradition of using string concatenation.
this.navCtrl.push("About1" + item);
aldoso
December 10, 2017, 2:22am
9
no luck
but console.log does show that it should actually work:
Do you have a page called About1Page
?
Alright, cool.
Do you have a AboutPage1.module.ts
file?
aldoso
December 10, 2017, 2:58am
13
about1.module.ts (export class About1PageModule) actually since the export class of about1.ts is About1Page
Hmmm.
What does the ionic info
command output?
aldoso
December 10, 2017, 3:18am
15
ionic info
cli packages: (C:\Users\alexdesk\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.0
ionic (Ionic CLI) : 3.19.0
global packages:
cordova (Cordova CLI) : not installed
local packages:
@ionic/app-scripts : 3.1.5
Cordova Platforms : none
Ionic Framework : ionic-angular 3.9.2
System:
Node : v8.9.1
npm : 5.5.1
OS : Windows 10
Environment Variables:
ANDROID_HOME : not set
Misc:
backend : pro
I would like to suggest you to setup a new small project with 2 lazy loaded pages and make that work\
And then compare stuff, especially in all module declaration
Also: try pushing the page not using dynamic string but static string âAbout1Pageâ to see if that works.
So build from a working thing and then expand slowly.
It is goingto be a nightmare debugging this way
aldoso
December 10, 2017, 9:33pm
17
I guess is time to declare this thread [Solved] because lazy loading actually can fix my need, so a big thanks to Tommertom & SigmundFroyd for your support!
So in conclusion, interpolation doesnât work basically in this case since it produces an error:
Good to hear
And if u want to know more about interpolation, study the angular guide on it
https://angular.io/guide/template-syntax
It is basically a feature of the template engine of angular and as such only works there. (And hence obviously will throw errors/unexpected results when using its syntax in typescript, javascript c#, assembly prolog, lisp pascal, react xamarin and so on and sonon)
1 Like