Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ionic2: ion-tabs tabs.getSelected().index got a Error: Cannot read property 'index' of null #10538

Closed
jeneser opened this issue Feb 23, 2017 · 1 comment

Comments

@jeneser
Copy link

jeneser commented Feb 23, 2017

Ionic version: (check one with "x")
[ ] 1.x
[ x ] 2.x

I'm submitting a ... (check one with "x")
[ x ] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

Current behavior:

Runtime Error
Error in ./HomePage class HomePage - caused by: Cannot read property 'index' of null

Stack
TypeError: Cannot read property 'index' of null
    at HomePage.onTabsChange (http://localhost:8100/build/main.js:56074:44)
    at CompiledTemplate.proxyViewClass.View_HomePage0.handleEvent_27 (/AppModule/HomePage/component.ngfactory.js:599:34)
    at CompiledTemplate.proxyViewClass.<anonymous> (http://localhost:8100/build/main.js:96697:37)
    at SafeSubscriber.schedulerFn [as _next] (http://localhost:8100/build/main.js:35084:36)
    at SafeSubscriber.__tryOrUnsub (http://localhost:8100/build/main.js:87920:16)
    at SafeSubscriber.next (http://localhost:8100/build/main.js:87869:22)
    at Subscriber._next (http://localhost:8100/build/main.js:87822:26)
    at Subscriber.next (http://localhost:8100/build/main.js:87786:18)
    at EventEmitter.Subject.next (http://localhost:8100/build/main.js:19527:25)
    at EventEmitter.emit (http://localhost:8100/build/main.js:35064:76)

Expected behavior:

When i used var tab_index = this.tabs.getSelected().index; in ionViewDidEnter() and onSlideDidChange(), all going well.I can get index.

But , i write var tab_index = this.tabs.getSelected().index; into onTabsChange(){}.I got the Runtime Error Cannot read property 'index' of null

Steps to reproduce:

reproduce:
http://plnkr.co/edit/BAy0Z7?p=preview

Related code:
Other information:

Ionic info: (run ionic info from a terminal/cmd prompt and paste output below):

Ionic Framework: 2.0.1
Ionic Native: 2.4.1
Ionic App Scripts: 1.1.0
Angular Core: 2.2.1
Angular Compiler CLI: 2.2.1
Node: 6.9.2
OS Platform: Linux 4.4
Navigator Platform: Linux x86_64
User Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/55.0.2883.87 Chrome/55.0.2883.87 Safari/537.36

Similar:
#10523

@ionitron-bot
Copy link

ionitron-bot bot commented Sep 3, 2018

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Sep 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant