Chrome app experiencing issues with Angular UI router

I am in the process of developing a chrome application using angularjs along with angular-ui-router.

app.js

var bar = angular.module('bar', [
    'ui.router',
])
.config(['$stateProvider', '$locationProvider',
    function($stateProvider, $locationProvider) {

    console.log("Everything seems to be functioning correctly.");

    $stateProvider
        .state('login', {
            url: '/',
            templateUrl: 'modules/login/templates/login.html',
            controller: 'loginController'
        })

}])

login.js

bar.controller('loginController',
    ['$scope',
    function($scope){

    console.log("This console log should display properly.");

}])

window.html

<!DOCTYPE html>
<html ng-app="mycurechrome">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">

    <script src="components/chromestrap/js/jquery-2.0.3.min.js"></script>
    <script src="components/chromestrap/js/bootstrap.min.js"></script>

    <script src="bower_components/angular/angular.min.js"></script>
    <script src="bower_components/angular-ui-router/release/angular-ui-router.min.js"></script>

    <script src="app.js"></script>
    <script src="modules/login/controllers/login.js"></script>

    <link href="components/chromestrap/css/bootstrap.min.css" rel="stylesheet">
    <link href="css/window.css" rel="stylesheet">

</head>
<body>
    <div ui-view></div>
</body>
</html>

manifest.json

{
    "name": "bar",
    "description": "foo",
    "version": "0.1",
    "manifest_version": 2,
    "app": {
        "background": {
            "scripts": [
                "background.js"
            ]
        }
    },
    "icons": { "16": "icon-16.png", "128": "icon-128.png" }
}

background.js

chrome.app.runtime.onLaunched.addListener(function() {
    chrome.app.window.create('window.html', {
        'outerBounds': {
            'width': 1000,
            'height': 600
        }
    });
});

In the app.js, the line

console.log("Everything seems to be functioning correctly.");
is executed as expected, however, the logging statement in login.js does not appear.

I believe I am implementing ui-router correctly, but I have some doubts because there might be a different technique for creating google chrome applications.

Answer №1

Make sure to redirect to the login state if it is set as your default state:

.config(['$stateProvider', '$locationProvider', '$urlRouterProvider',
    function($stateProvider, $locationProvider, $urlRouterProvider) {

    console.log("Everything is running smoothly.");
    $urlRouterProvider.otherwise('/login');
    $stateProvider
        .state('login', {
            url: '/login',
            templateUrl: 'modules/login/templates/login.html',
            controller: 'loginController'
        });

}]);

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

Error - IO Is Not Defined in Socket.io

Currently, I am developing a real-time chat web page. Initially, I was considering using PHP, but I am experimenting with socket.io for the backend. However, I have encountered an issue where the browser console displays Uncaught ReferenceError: io is not ...

Using an AngularJS directive to dynamically incorporate Bootstrap classes in the HTML elements

Our application is now incorporating reusable code by creating a simple directive to display content efficiently. Directive Code: angular.module("newsStore.moduleDirectives", []) .directive('renderAboutContent', ['aboutService', r ...

How the Material-UI Tooltip zIndex takes precedence over the MenuItem in the Select component

My issue is quite straightforward. I have a <Tooltip> component wrapping a <Select> component, and when I click the Select, the tooltip appears above the MenuItems like this: Expected behavior: https://i.sstatic.net/VOVmf.png Unexpected beha ...

Event that signifies a change in the global state of the Angular 2 router

Is there a universal event that can be utilized for state change/start across all components, similar to the Component Lifecycle Hooks ? For example, in UI-router: $rootScope.$on("$stateChangeStart", function() {}) ...

What is a reliable method to retrieve the text from the current LI if all LI elements in the list share the

I'm encountering an issue with retrieving the text from LI elements because I have 10 list items and they all have the same class name. When I attempt to fetch the text using the class name or id, I only get the text of the last item. Here is my code ...

Having issues executing the test suite in Firefox or any other browser with Selenium RC

I am new to Selenium and recently faced a challenge that I couldn't solve. I'm attempting to execute the following suite in either Firefox or Chrome: C:\auto_tools>java -jar selenium-server-standalone-2.46.0.jar -htmlSuite "*googlechrom ...

When redirecting to a .scala.html file in Scala Play, only text is displayed, not the full

I recently set up the Google OAuth hybrid server-side flow, which involves making an AJAX call to retrieve an access token. Upon successfully storing the token, I want the server to display content using a file named home.scala.html. // This function is c ...

What is the process for closing the lightbox?

My code is supposed to display a lightbox as soon as the page loads, similar to a popup window. However, there seems to be an issue with closing the lightbox when clicking on the 'x' button at the corner of the box. Unfortunately, the current cod ...

Unable to retrieve private field using a public getter method through a proxy

When retrieving data from a VueX Module using a Getter, the Object is enclosed within a Proxy that triggers the following error: TypeError: attempted to get private field on non-instance when attempting to access a private property with a public getter. ...

Error: Template Root is Invalid

I decided to implement AngularJS into my Play 2.0 application based on the guidance from Paul Dijou's informative blog post about HTML5 routing. Essentially, the Play framework serves the index.html file for any unknown routes, allowing AngularJS rout ...

AngularJS: Triggering an event before the radio button value is changed

Is there a way to detect the value change of a "radio button" before it actually changes in my application? I need to inform the User about the consequences of changing the value of this radio button within the form. I've experimented with using ngC ...

Apply a custom CSS class to every `tr` element that includes a particular value

I'm attempting to assign a class to a tr element (last_value_row) in a form when the target value in the first td of the last_value_row element is "New Target". Currently, only the first element will have the class added, while all other elements with ...

What is the ideal usage of promises in ES6 node projects?

The official bluebird promises page suggests that when using node.js, there may not be a need to manually write promises. Recently, while working on a new project, I noticed that my code heavily relies on promises. For instance, I have a databaseConnector ...

Reprinting information from my server / overlooked a task

After saving "Ben and Jerry's" to my database and retrieving it later for editing/resaving in an input tag, I am encountering an issue. Ben & Jerry&#39;s What could be the problem? (I have noticed that the "&" is correctly translated but ...

Box2dweb: Interaction Point of Collision

Currently working with box2dweb for a game development project. Need assistance in determining the contact point between a "Circle" and "Box". Aware that this can be achieved through b2ContactListener and the Post-Solve Event. Seeking guidance on impleme ...

An async function cannot be used as a Constructor

I am in the process of creating a constructor function using JavaScript. This constructor needs to be asynchronous because I am utilizing the Phantom JS module for data scraping. As a result, an asynchronous function must be used to scrape data through Pha ...

The dropdown list is not getting populated with data retrieved from an HTTP response

My experience with making HTTP calls is limited, and I am facing an issue while trying to populate specific properties of each object into a dropdown. Despite attempting various methods, such as using a for loop, the dropdown remains empty. created(){ a ...

When using `res.send()`, an error of Type Error may be encountered stating that the callback is not a function. However, despite this error,

I am currently working on a function for my Node.js server, using Express as the framework and MongoDB as the database. This function involves calling two mongoose queries: (1) Retrieving filtered data from one collection (2) Aggregating data from anothe ...

Cookies are failing to set through NPM requests

// Import the necessary module const request = require('request'); // Define the API URL let api_url = 'https://some-api-that-requires-cookies.com' // Create a cookie jar to store cookies const cookieJar = request.jar(); let cookie = ...

Creating a mesh using Three.jsWould you like to learn how to

I have an .obj file v 1 2 3 v 4 5 6 v 7 8 9 vt 0 1 vt 1 0 vn 0 0 1 vn 0 1 0 vn 0 0 1 f 1/1/1 2/2/2 3/3/3 f 1/1/2 2/2/3 1/2/3 My goal is to generate a THREE.Mesh. Here's what I'm doing: var geometry = new THREE.BufferGeometry(); geometry.add ...