The pushPage functionality in Onsen UI seems to be malfunctioning

I am currently utilizing onsen UI's ons splitter along with a side menu. Interestingly, I am encountering an issue where the nav.pushpage function does not seem to work within the googleloginfunction.

Please take a look at the code provided below.

HTML

<ons-navigator var="nav">
        <div ng-controller="MainController"></div>
    </ons-navigator>

    <ons-template id="login.html">
      <ons-page>
        <ons-toolbar>      
          <div class="center">
            CRGroup
          </div>
        </ons-toolbar>
        <div align="center" style="padding: 8px" id="deviceready">
            <br/>
            <img src="img/logo2.png"/>
            <br/>
            <ons-button modifier="large" onclick="googlelogin()">Sign In with Google+</ons-button>
        </div>
      </ons-page>
    </ons-template>

    <ons-template id="principal.html">
        <ons-splitter var="mySplitter" ng-controller="SplitterController as splitter">
          <ons-splitter-side side="left" width="220px" collapse>
            <ons-page>
              <ons-list>
                <ons-list-item ng-click="splitter.load('home.html')" tappable>
                  Home
                </ons-list-item>
                <ons-list-item ng-click="splitter.load('home2.html')" tappable>
                  Home 2
                </ons-list-item>                
              </ons-list>
            </ons-page>
          </ons-splitter-side>
          <ons-splitter-content page="login.html"></ons-splitter-content>
        </ons-splitter>
    </ons-template>

    <ons-template id="home.html">
      <ons-page>
        <ons-toolbar>
          <div class="left">
            <ons-toolbar-button ng-click="mySplitter.left.open()">
              <ons-icon icon="md-menu"></ons-icon>
            </ons-toolbar-button>
          </div>
          <div class="center">
            Main
          </div>
        </ons-toolbar>
        <p style="text-align: center; opacity: 0.6; padding-top: 20px;">
          Swipe right to open the menu!
        </p>
      </ons-page>
    </ons-template>
    <ons-template id="home2.html">
      <ons-page>
        <ons-toolbar>
          <div class="left">
            <ons-toolbar-button ng-click="mySplitter.left.open()">
              <ons-icon icon="md-menu"></ons-icon>
            </ons-toolbar-button>
          </div>
          <div class="center">
            Main 2
          </div>
        </ons-toolbar>
        <p style="text-align: center; opacity: 0.6; padding-top: 20px;">
          Swipe right to open the menu!
        </p>
      </ons-page>
    </ons-template>

Javascript

<script type="text/javascript">

        var app = angular.module('my-app', ['onsen']);

        app.controller('MainController',function($scope){
            $scope.nav.pushPage('principal.html');
        });

        app.controller('SplitterController', function() {

            this.load = function(page) {
              mySplitter.content.load(page).then(function() {
                  mySplitter.left.close();
                });
            };
          });
        function googlelogin($scope) {      
            window.plugins.googleplus.login(
                {},
                function (obj) {
                alert(obj);
                    if(obj != null) {               
                        window.localStorage.setItem("userid", obj.userId);
                        window.localStorage.setItem("name", obj.displayName);
                        window.localStorage.setItem("email", obj.email);
                        window.localStorage.setItem("profilepic", obj.imageUrl);
                        $scope.nav.pushPage('home.html');

                    }
                    else {
                        alert("Something went wrong! Please try again later.");
                    }
                },
                function (msg) {
                    alert(msg);
                }
            );
        }

    </script>

Essentially, my setup involves an ons splitter in combination with angular js. Upon successful execution of the google login function, my objective is to navigate to the home.html template. Any assistance would be greatly appreciated.

Answer №1

To incorporate the ons-navigator into the ons-splitter, make sure to place it within the ons-splitter-content element.

<ons-splitter-content>
     <ons-navigator var="nav" page="home.html"> </ons-navigator>
</ons-splitter-content>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Assetic in Symfony2 causing issues with AJAX requests

Recently, I encountered a strange issue while working on my Symfony2 application. The problem arose when I integrated assetic with the uglifyjs filter for JavaScript files. Everything functioned perfectly when the JavaScript files were included as individu ...

Using Ajax to invoke a C# webmethod

I'm trying to call a webmethod defined in this specific class <%@ WebService Language="C#" Class="emt7anReyady.myService" %> using System; using System.Web; using System.Web.Services; using System.Web.Services.Protocols; using System.Linq; usi ...

Utilizing ReactJS useState to eliminate a className

Basically, I'm trying to remove a className from an element when a button is clicked. I've attempted to use useState hooks and a regular function, with the onClick event on the button triggering this function/setUseState. However, the className l ...

Experiencing an excessive number of re-renders can be a common issue in React as it has limitations set in place to prevent infinite loops. This

I have integrated React context to access the login function and error from the context provider file for logging into the firebase database. I am trying to display any thrown errors in the app during the login process. However, I encountered an issue whe ...

Protractor encounters an "Error starting WebDriver session" message

After starting a server with webdriver-manager start, encountering an error when attempting to run protractor: Using the selenium server at http://127.0.0.1:4444/wd/hub [launcher] Running 1 instance of WebDriver ERROR - Unable to initiate a WebDriver sess ...

Unable to trigger onClick event in React class-based component

I came across the following code for a class-based component: class PostLike extends Component { constructor(props) { super(props); this.state = { likes: null, like_id: null } this.likeSubmit = t ...

The Tinymce toolbar buttons are missing text labels, leading to an accessibility issue in the audit

When using Tinymce, the toolbar buttons only display icons without any text. This has been causing issues with accessibility audit tools such as WAVE. Does anyone know how to add hidden text to these buttons? Thank you ...

Escape from the AngularJS Template Expression sandbox

Recently, I came across an interesting article discussing a sandbox escape vulnerability in AngularJS. You can find the article at this link. The issue has been patched in AngularJS 1.3.2. I'm curious to know if versions 1.2.26 and 1.2.27 of AngularJ ...

Using jQuery to submit data via POST method without having the page reload

I have a link in the footer that, when clicked, jumps to the header with a # in the address bar. Is there a way to prevent this and stay in the footer? Here is the code snippet: <a href="#" class="clickIn" id="1" attrIn="Like"><span style="color ...

Creating Vue3 Component Instances Dynamically with a Button Click

Working with Vue2 was a breeze: <template> <button :class="type"><slot /></button> </template> <script> export default { name: 'Button', props: [ 'type' ], } </scr ...

How to change elements within an HTML string using jQuery

I am facing an issue where I have an HTML string (not DOM) that needs to be manipulated using jQuery. However, the code I am trying does not seem to work as expected: var html = '<div><h4><a class="preview-target" href="content.html"&g ...

Unbind a prepared statement in a node.js environment using SQL

Utilizing the node-mssql library (https://github.com/patriksimek/node-mssql) and encountered a problem when attempting to execute a second request, resulting in the following error: this.connection.pool.acquire(done); ^ TypeEr ...

Contrast and analyze two groups of items

In my application, I have a scope named $scope.users that contains information about all the users, such as: [{"id":1,"name":"Peter Boomsma"}, {"id":2,"name":"Jan Jansen"}, {"id":3,"name":"Kees Keesen"}, {"id":4,"name":"Piet Pietersen"}] Additionally, ...

Switching database connections based on routes in express.js using sequelize

Can the database connection in sequelize be modified based on the route? For instance, Users can access 2 different installations on a website: - example.com/foo - example.com/bar When users log in, they are directed to example.com/foo. To view all th ...

Tips for handling uncaught exceptions in Internet Explorer

In both Chrome and Firefox, it is possible to suppress exceptions, but unfortunately, this is not the case with Internet Explorer (IE). window.addEventListener("error", function errorHandler(event) { console.log("exception should be suppressed and not ...

Encountering a "Error 404: Page Not Found" message when trying to request a json object from a node server

Working on a RESTful API, I have set it up to run on node.js using express.js, mongodb with mongoose for object modeling, and body-parser for passing HTTP data. However, whenever I start the server and try to access the specified IP address, I encounter a ...

Ways to conceal an element in Angular based on the truth of one of two conditions

Is there a way to hide an element in Angular if a specific condition is true? I attempted using *ngIf="productID == category.Lane || productID == category.Val", but it did not work as expected. <label>ProductID</label> <ng-select ...

Error validator failed for Mongo Db: Masekhta validation failed with error for _id field, expecting `_id`

I am struggling with creating simple scripts to add an object to MongoDB, and I keep encountering this error message: Error: Masekhta validation failed: _id: Error, expected _id I can't figure out why this is happening. My guess is that it might be r ...

Use jQuery to dynamically update a text field within a table row based on a selection from

My understanding of JS and jQuery is not very strong. This is the HTML Output I created using a foreach-loop: $('#ProjectOfferPosition0IsystemTypeVariantId').on('change', function () { var prices = []; prices[1] = 500.00; ...

Solving the conundrum of sending a Javascript date object (formatted datetime) through Laravel API

When my Laravel 5 API fetches datetime columns from my MySQL database, the JSON output is in this format: 2015-08-13 13:45:00 However, the widget that reads this JSON data expects a JavaScript Date Object. How can I convert my datetime to a JavaScript Da ...