The issue with Mobile Angular's ng-view not functioning on a PhoneGap application was identified

Embarking on my first mobile app adventure with Mobile Angular and PhoneGap.

The current setback involves the template files not loading in the ng-view of the PhoneGap test app on the phone.

I'm aware this issue has been raised before:

Even after attempting to incorporate aHrefSanitizationWhitelist(), the problem persists.

Edit:

This is how the file appears at present:

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />

    <meta name="apple-mobile-web-app-capable" content="yes" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="msapplication-tap-highlight" content="no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width" />

    <!-- Wide open CSP declaration. Adjust for production. -->
    <meta http-equiv="Content-Security-Policy" content="default-src * 'unsafe-inline'; style-src 'self' 'unsafe-inline'; media-src *" />

    <link rel="stylesheet" href="./css/mobile-angular-ui-hover.min.css" />
    <link rel="stylesheet" href="./css/mobile-angular-ui-base.min.css" />
    <link rel="stylesheet" href="./css/mobile-angular-ui-desktop.min.css" />

    <link rel="stylesheet" type="text/css" href="./css/index.css" />

    <title>Hello World</title>

</head>

<body ng-app="myApp">

    <div class="app">

        <!-- Top Navbar -->

        <div class="navbar navbar-app navbar-absolute-top">

              <div class="btn-group justified">
                <a href="#/page1" class="btn btn-navbar">Page 1</a>
              </div>

        </div>

        <!-- Bottom Navbar -->

        <div class="navbar navbar-app navbar-absolute-bottom"></div>

        <!-- App Body -->
        <div class="app-body">

            <div class="app-content">

              <ng-view></ng-view>

            </div>

        </div>

    </div><!-- ~ .app -->

    <!-- Modals and Overlays -->
    <div ui-yield-to="modals"></div>

</body>

<!-- Libs -->
<script src="cordova.js"></script>

<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-route.min.js"></script>

<script src="/js/mobile-angular-ui.min.js"></script>
<script src="/js/mobile-angular-ui.gestures.min.js"></script>

<!-- App -->
<script>
var app = {
    initialize: function()
    {
        this.bindEvents();
    },
    bindEvents: function()
    {
        document.addEventListener('deviceready', this.onDeviceReady, true);
    },

    onDeviceReady: function()
    {
        angular.element(document).ready(function()
        {
            angular.bootstrap(document, ['myApp']);
        });
    },
};


angular.module('myApp', ['ngRoute']).config(function($routeProvider)
{
    $routeProvider
    .when('/', {
        templateUrl: './views/page1.html'
    })
    .when('/page1', {
        templateUrl: './views/page1.html'
    });

});

app.initialize();
</script>

</html>

Answer №1

CASE CLOSED!:

After conducting my own investigation, I discovered the issue. Initially, I checked if the angular script was loading properly, especially on mobile devices where it wasn't working as expected. This led me to realize that the problem did not lie with routing but rather with angular not being loaded correctly.

The fix involved adding https: before //:

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.6/angular-route.min.js"></script>

Update:

Alternatively, you can opt for a local solution:

<script src="js/angular.min.js"></script>
<script src="js/angular-route.min.js"></script>

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

JavaScript code that moves the active link to the top of the navigation when the window width is less than or equal to 800px

I'm working on a responsive navigation that is fixed at the top and switches from horizontal to vertical when the screen size is less than or equal to 800 pixels wide. However, I'm facing an issue with moving the active link to the top of the na ...

Refresh the data using the Ajax function

I am attempting to implement a delete function using Ajax. function delCatItem(catitem){ var theitem = catitem; $.ajax({ url: "movie/deleteitem/", type: "POST", data: { "movieid" : catitem ...

Vue combined with Grapejs

Currently, I am utilizing Grapejs with Vue and everything appears to be functioning properly. However, I am encountering an issue with the "grapesjs-preset-webpage" library. I am struggling to incorporate additional HTML options, such as "Columns", "Video ...

Maximizing search engine optimization for an AngularJS website

What is the best approach for implementing search engine optimization (SEO) on a website created using AngularJS? Kindly provide an explanation of the methods and techniques that can be used. ...

Unable to make changes to a file authored by a different user within Firestore using Vue.js / Firestore

I appreciate any assistance in advance, as this issue has been causing me a lot of frustration! Currently, I am adhering to the firestore data model where users are able to create their own documents associated with their userID. This ensures that users c ...

Exploring Angular2: Implementing oauth2 with token headers

As someone who is new to Angular 2, I found that things were much simpler with interceptors in version 1.*. All you had to do was add them and suddenly your headers were available everywhere, making it easy to handle requests especially when dealing with i ...

Navigating with buttons in React JS

In my material-ui, I have a button set up like this: <Button style={green} raised="true" label="Continue to create group"}> CREATE NEW GROUP </Button> I am looking to make it so that when the button is clicked, it will take me ...

When the icon is clicked, initialize the jQuery UI Datepicker

Here is the code I am working with in a Backbone view: <input type="text" id="fromDate" name="fromDate"/><a id="cal"> <img src="img/calendar.gif"></a> Within the view's JavaScript file, I have implemented the following: defi ...

Locate and substitute `?php` and `?` in a given string

I am facing a challenge with inserting a large string of valid HTML code into the DOM, as the string also includes PHP code. When Chrome renders the code, it automatically comments out the PHP sections. The PHP code is encapsulated in <?php ... ?>, s ...

Before the async function, make sure to set the value using React's useState

Exploring the world of react context api for the very first time. Below is my react code utilizing the context api: const [valChanged, setValChanged] = useState(false); async function modalSave() { await setValChanged(true); // STEP 1 await o ...

A guide to performing individual file testing in Quasar testing

I need to run specific test code in my Quasar project without running all tests. I've tried using the following commands, but they still run all test files. quasar test --unit jest -t "demo/demo.spec.js" quasar test --unit jest --spec "demo/demo.spec ...

Retrieve data from external URL using API

I am encountering a captchas page when attempting to retrieve JSON data from a URL through my API. Even though I am trying to access an array of JSON data containing openPrice, highPrice, price, and lowPrice, all I seem to get is a captcha form instead of ...

Error: The reference to WEBGL has not been properly defined

Within my HTML, the code snippet below is causing an issue: if (WEBGL.isWebGLAvailable()==false) { document.body.appendChild(WEBGL.getWebGLErrorMessage()); } Upon running this code, the following error appears in the console: Uncaught ReferenceErr ...

Oops! An error has occurred with the module in angular1

I recently integrated ui-router into my Angular 1 application and set up the route state. However, I encountered an error when trying to access the page mentioned in the title of this post. Below is the code snippet for reference. Can anyone point out wher ...

Forcing an HTML5 video source update within an AngularJS project

I'm currently working on a project that involves embedding an HTML5 video onto a view. The video source is dynamically populated using $scope. Initially, the player works perfectly with the video I first load. However, when the video ends, I attempt t ...

What could be the reason for v-model not functioning properly?

Embarking on my Vue.js coding journey, I am currently following a straightforward online tutorial. Utilizing the vue-cli, I kickstarted my application and crafted a basic component named Test.vue. Within this component lies a simplistic input control conne ...

After 30 seconds of inactivity, apply the CSS once, then remove it before repeating the process

I've got a unique little CodePen with an animation that I want to execute only if the user hasn't clicked on the <div class="someDiv"> for 30 seconds. My question is, can someone guide me in the right direction so that when someone doesn&a ...

What is the process for modifying the popups associated with a polygon object?

As of now, every time I click on the map, a popup shows up with the name of the country based on a geoJSON file containing multi-polygon lnglat coordinates that outline the borders of each country. This method saves me from manually inputting each country& ...

Oops! Looks like we encountered a fatal error while running the unit tests. Unfortunately, the unit

After setting up the project environment and successfully installing grunt, I attempted to run grunt in the terminal which resulted in the following output: https://i.stack.imgur.com/4xnll.png I proceeded to follow the steps. Running grunt build --env ...

Creating a plotly.js integration for nuxt SSR: A step-by-step guide

Currently facing issues with setting up plotly.js in my nuxt project. Despite trying various approaches, I keep encountering the error message self is not defined. Installing both plotly.js and plotly.js-dist did not resolve the issue. My attempt to creat ...