constructor(public nav: NavController) {
this.storage = new LocalStorage();
this.site = this.storage.get("nsSite");
if(this.site.value == null) {
console.log(this.site);
console.log("no site set");
this.doRadio();
}
doRadio() {
let alert = Alert.create();
alert.setTitle('Select Site');
alert.addInput({type: 'radio', label: '1', value: '1', checked: true});
alert.addInput({type: 'radio', label: '2', value: '2'});
alert.addInput({type: 'radio', label: '3', value: '3'});
alert.addInput({type: 'radio', label: '4', value: '4'});
alert.addButton('Cancel');
alert.addButton({
text: 'OK',
handler: data => {
console.log('Site:', data);
this.plantRadioOpen = false;
this.plantRadioResult = data;
this.storage.set("nsSite", data);
this.site = data;
}
});
why does this return too a blank screen instead of the template. if i take out this.doRadio() the template loads just fine. do i need to do something else?
1 Like
In the code-fragment above the closing bracket of the constructor is missing. I can’t tell if this is the problem though, because the source code is not complete and you might removed it by mistake when pasting. I would recommend you to use an editor with syntax checking and Intellisense support such as VS Code .
that was just me not copying and pasting the whole thing. its there in the actual program… but good eye. Other thoughts? Its like once the doRadio runs it never finishes rendering the view.
brandenwagner:
Other thoughts?
Without seeing the complete code of the doRadio()
method (because it’s also only partial code sample) I can only guess why it’s not working. But most probably there’s an error in your code/implementation or you’re missing an import. The reason for the blank screen is something related to the following issue, I guess:
opened 04:19PM - 04 May 16 UTC
closed 07:07PM - 06 May 16 UTC
#### Short description of the problem:
When there's an error in the code _(Java… Script/TypeScript/HTML)_ it is not displayed in the console.
#### What behavior are you expecting?
A error should be displayed in the console to indicate that something is wrong with details about the cause.
**Steps to reproduce:**
1. Make sure to test on **Mac OS X El Capitan**.
2. Start a new project: `ionic start TestAppJS blank --v2`.
3. Replace the content of `home.js` with the code below.
4. Run `ionic serve`.
5. Observe that no error is shown in the console.
``` js
// NOTE: Intentionally not importing Storage so that an exception is thrown.
import {Page, NavController, SqlStorage} from 'ionic-angular';
@Page({
templateUrl: 'build/pages/home/home.html'
})
export class HomePage {
static get parameters() {
return [[NavController]];
}
constructor(nav) {
this.db = new Storage(SqlStorage);
}
}
```
**Other information:** (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
- Related issues: #6217, #6253, #6259 _(all of them with various error causes but the same end result - no error is shown, when it should be - and all of them on Mac OS X)_
- Forum links:
- https://forum.ionicframework.com/t/simple-sqlstorage-setup-breaks-with-no-stacktrace/50670
- https://forum.ionicframework.com/t/white-screen-for-ios-only/50802
- https://forum.ionicframework.com/t/ionic-2-error-not-showing-in-nav-push-somepage/49418
**Which Ionic Version?** 2.x
#### Plunker that shows an example of your issue
Not reproducible in Plunker - seems to be a platform-specific issue _(Mac OS X)_
**Run `ionic info` from terminal/cmd prompt:** (paste output below)
> **NOTE:** The info below is summarized across all reports and related issues.
```
Cordova CLI: 6.1.1 / Not installed
Ionic Framework Version: 2.0.0-beta.4 / beta.5 / beta.6
Ionic CLI Version: 2.0.0-beta.17 / beta.24 / beta.25
Ionic App Lib Version: 2.0.0-beta.8 / beta.14 / beta.15
OS: Mac OS X El Capitan (all of them)
Node Version: v4.2.2 / v4.4.3 / v5.1.1 / v5.8.0 / v5.10.1
Xcode version: Xcode 7.2 / 7.3 / Not installed
```
Sorry, i kind of forgot about this issue, i was working on something else. So here is my full code
ngOnInit(){
if(this.site == null) { this.doRadio();}
}
public doRadio() {
let alert = Alert.create();
alert = Alert.create();
alert.setTitle('Select Site');
alert.addInput({type: 'radio', label: '1', value: '1', checked: true});
alert.addInput({type: 'radio', label: '2', value: '2'});
alert.addInput({type: 'radio', label: '3', value: '3'});
alert.addInput({type: 'radio', label: '4', value: '4'});
alert.addButton('Cancel');
alert.addButton({
text: 'OK',
handler: data => {
alert.dismiss();
this.site = data;
this.storage.set("nsSite", data);
return false;
}
});
this.nav.present(alert);
}
public calculate(){
var temp: any;
if(this.site == null) {
this.doRadio();
}
for(let crew of this.crews){
temp = this.sc.shift(this.dt, crew.id, this.site);
crew.shift = temp.name;
crew.day = temp.day;
crew.hours = temp.hours;
crew.plus = temp.plus;
}
}
}
So the problem is that when doRadio runs, i do in fact get the alert. user can then change to one of the 4 options and the data is set in localstorage. The alert closes and the app is no longer usable. Its as if everything is frozen. Like the alert modal has still taken control even though its no loner visible
To fix this ive discovered you just have to add
this.nav.push(ThePage);
to the handler
Thank you for you code, it really helped me with my problem.
I solved your issue I just added
alert.present(prompt);