I have created a project added all the references and added highcharts reference in package.json. But require not found is displayed.
Add a variable declare var require: any; in app.module.ts
Related
The Ionic 5 documentation says:
The textarea component accepts the native textarea attributes in addition to the Ionic properties.
But this does not apply to CSS properties of the native textarea, so how is it possible to make the ion-textarea element resizable?
You can try using the below plugin:
https://www.npmjs.com/package/ngx-autosize
OR
npm i ngx-autosize
import { AutosizeModule } from 'ngx-autosize';
below is the code i used in ionic/angular to make the ion-textarea resize:
<ion-textarea
[minRows]="1"
[maxRows]="5"
autosize
placeholder="Start writing..."
></ion-textarea>
you need to import it in and imports array in app.module and page.module where you need to use it.
I'm trying import css just like I do normally in react.
import "#styles/my_lovely_component.sass"
It obviously shows the error that I cannot import global styles in components. If I change the name from my_lovely_component.sass to my_lovely_component.module.sass, the error is suppressed but the styles aren't really applied/included on my page or components.
I found out people use component styles like this
import styles from "#styles/my_lovely_component.module.sass"
const JustAComponent = () => <img className={styles.doggo_img} />
This gets annoying very quickly. I literally have been working by importing all styles globally in __app.ts, because I couldn't find a working solution to import styles like the good old(well not really old) way.
Any help will be appreciated. Thanks.
(I did consider the other styling methods like styled-jsx/components, emotion and stuff. But they're even more annoying.)
If you want to add global styles for your next project
At first you need loader in next-config.js
then read about _document.js where you can add global styles to the head.
Code:
Working for the first time:
Showing error after refreshing the page:
Can anyone can help on this?
BrowserModule is imported in app.module.ts and CommonModule is imported in child module.
It is a tabbed application
I tried to override sass variable in variables.css like this
but it's not what I want.
It seems to change the styles of all tabs.
You just need to do as shown below on the page component which you need to apply.
my.scss
.ios,
.md,
.wp {
page-my {
.margin-top-15 {
margin-top: 15px;//this is just an example
}
}
}
Currently, it is not possible to override a sass variable in one single page, it simply does not work.
This is the response to a similar issue reported in ionic forums:
https://github.com/ionic-team/ionic/issues/7469
One useful solution is to ionic serve your project, open the inspector on your browser, inspect the desired element and see its ionic generated classes to overwrite them manually in the .scss file.
Currently you cannot change sass variables in one page. That's just not how sass works. Sass is meant to be used as a global setting.
There is a work around to change let's say for example the background of a loading container.
You can do this for most.
If you open developer tools and select inspect element on the loading wrapper it gives the class .loading-wrapper as shown in image link below.
css class for loading shown in inspect element
In your app.css
.loadingCss {
.loading-wrapper {
color: #f4f4f4;
background: #2979ff;
}
}
in your component ts add the class to your loading create instance
//initialize a loading overlay
let working = this.loadingCtrl.create({
content: 'Working...',
spinner: 'dots',
cssClass: 'loadingCss'
});
Now you can create multiple instances of loading and have separate classes for loading and add them to your instance and the css will take effect.
Final result is shown in the below image link.
Loading overlays with custom css on two pages
I hope this helps
I have recently upgraded to ionic 3 implementing the IonicPageModule for navigation. The push and setRoot works for all navigating however i am stuck at the trying to reference the pages in the app.component.ts
Normally i would reference the page from the import like so
this.rootPage = user ? ProgramsPage : LoginPage;
Where LoginPage and ProgramPage are declared in the app.module.ts
However in the new angular 4 / ionic 3 setup references to the "pages" are referenced with strings without an import in the related page.ts and seemly integrated with the navCtrl's push and set
I have tried
import { LoginPageModule } from '../pages/login/login.module';
But that does not make sense.
I figured the whole point of creating modules per page was to firstly enalble lazy loading but also minimize the import code on pages without having to create a config export class.
And the thing is you cannot declare the LoginPage twice and seeing as though it is already declared as a module through the IonicPageModule one cannot add that export class again.
So just wondering how do you reference a ionic 3 page module when you want to apply logic?
I came across an article that implemented close to what you really wanted; though it talked more about cloud functions but at the beginning it tried to solve your problem in a very fashionable way. Take a look https://javebratt.com/firebase-cloud-functions-profile/
if your pages are being declared as:
/* imports and stuff here ... */
#IonicPage()
#Component({
selector: 'page-user',
templateUrl: 'user.html'
})
export class UserPage { /* constructor, your code & else ... */ }
or generated using the ionic-cli by running: ionic g page NewAppPage
you will be able to use the string page name instead of using the page object (that also requires you to import the page).
Take a look at https://www.javascripttuts.com/ionic-3-new-pages-lazy-loading/ , it may help you understand a little bit more about lazy loading and pages inside the app component.