ng-view or controller appears to be malfunctioning

I'm currently working on a small web application using AngularJS. I have an index.html file in the main directory and three other HTML pages within the html subdirectory.

  • login.html
  • list.html
  • detail.html

    1. Initially, the index.html should load the login.html. This page contains three input fields to login into a validation system. Once the login is successful:

    1.2 the index.html loads the list.html page and when an element from the list is clicked,

    1.3 the index.html displays the details stored in detail.html. A typical web application flow.

Currently, my index.html is not showing any code from login.html!

Below is the code snippet:

HTML part

index.html

<!DOCTYPE html>
<html  >
    <head lang="en">
        <meta charset="UTF-8>
        <title>CV Alibo - Tab</title>
        <link rel="stylesheet" href="./css/style.css"/>
        <script src="./lib/angular.js"></script><!-- angular-min.js , version stable by angularJS.org -->
        <script src="./lib/angular-route.js"></script>
        <script src="./js/cvAliboApp.js"></script>
        <script src="./js/cvAliboController.js"></script>
    </head>
    <body ng-app="cvAliboApp">
        <div>
            <h1>Test JS</h1>
            <p>Between two rows, you can see more pages.</p>
        </div>
        <hr/>
        <div ng-view>
        </div>
        <hr/>
    </body>
</html>

html/login.html

<div ng-controller='cvAliboLogin'>
    <h1>CV Alibo - Login</h1>
    <p>
        <input type="text"    name="username" >
        <input type="password"    name="password" >
        <input type="button"  name="login" >
    </p>
</div>

html/list.html

<div ng-controller='cvAliboList' id="list">
        <h1>LIST</h1>
</div>

html/detail.html

<div ng-controller='cvAliboDetail' id='detail'>
    <h1>DETAIL</h1>
</div>

Javascript

js/cvAliboApp

'use strict';


var cvAliboManager = angular.module('cvAliboApp', ['ngRoute']).
config(function($routeProvider) {
    $routeProvider
        .when('/', {
            templateUrl:'html/login.html', controller: 'cvAliboLogin'
      }).when('/list', {
            templateUrl:'html/list.html',   controller: 'cvAliboList'
      }).when('/list/:id', {
            templateUrl:'html/detail.html', controller: 'cvAliboDetail'
      }).otherwise({redirectTo: '/'});
});

js/cvAliboController.js

'use strict';

var cvAliboManager = angular.module('cvAliboApp', []);
    cvAliboManager.controller('cvAliboLogin',
        function cvAliboLogin($scope) {
           alert("cvAliboLogin");
        }
    );

    cvAliboManager.controller('cvAliboList',
        function cvAliboController($scope) {
            alert("cvAliboList");
        }
    );

    cvAliboManager.controller('cvAliboDetail',
            function cvAliboController($scope) {
                alert("cvAliboDetail");
            }
        );

    /*
     * There might be a syntax error in module.run which has been commented out to avoid loading Javascript code with errors.
    */
  • AngularJS Version used is 1.2.18.
  • The angular-routing file has been imported successfully.
  • Using alerts, it appears that there might be a syntax error in the commented out module.run section.
  • All JavaScript files are correctly imported for use.
  • The constructors have been declared and implemented properly.

Why isn't my index.html displaying the login.html? Any suggestions would be greatly appreciated...

Answer №1

It seems like the issue lies in the initial line of your js/cvAliboController.js file: When you declare

var cvAliboManager = angular.module('cvAliboApp', []);
, you are essentially redefining your application without any dependencies, such as ngRoute. As a result, the routes cannot be resolved and nothing will be displayed.

One possible solution is to remove the empty brackets:

var cvAliboManager = angular.module('cvAliboApp');

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

What is the best way to assign JSON data to a Class variable within Angular?

In my code, I have a class called Projects export class Projects { project_id: number; project_name: string; category_id: number; project_type: string; start_date: Date; completion_date: Date; working_status: string; project_info: string; area: string; add ...

"Efficiently fetch data with an Express GET request without the

My goal is to send the client the HTML page (create.html) in response to a GET request triggered by a button click using fetch. I am intentionally avoiding the use of a form due to formatting and potential scalability issues. The code acknowledges that the ...

Using the && operator for conditional rendering in a React return statement

How should I format my return statement in a class component when using the && operator in the condition like this: if (x === null && y === null) If the condition is met, display this HTML: <div className="col-12"> <SomeComponent /> < ...

Comparing Nodes Armed with Clusters to Nodes Sporting Threads

Can you explain the key distinctions between node cluster and Threads agogo, including their respective advantages and disadvantages? From my understanding, Threads agogo creates a background thread while node cluster initiates a new process to run in th ...

having difficulty with the design of my google map

Struggling to style my Google Map this week - I have the JSON values but no clue how to add them into the JavaScript. Also, need to move the zoom bar control to the right instead of it being hidden behind site content on the left. Any help would be greatl ...

Tick the checkboxes that are not disabled, and leave the disabled ones unchecked

Currently, I am employing Jquery for the purpose of checking and unchecking checkboxes. However, some of these boxes are disabled, thus there is no need for them to be checked. Is there a method by which I can instruct the script to disregard disabled che ...

Implementing a function in ReactJS that is activated by multiple buttons

Apologies for the unclear title. My issue revolves around having three different button tags, each of which should send a unique argument to the function selectSupplier(). However, no matter which button is clicked, only the last value ("ultramar") is be ...

Guide to designing a unique shape in JointJs by combining multiple basic shapes together

Is there a way to combine different shapes in Joint JS, such as creating a custom shape that includes both a rectangle and a circle? I am aware of the path method, but I'm not sure if it is suitable for creating combined shapes like this. ...

Step-by-step guide on retrieving JSONP data from Angular service within view by utilizing expressions

I have been developing an Angular application that retrieves data from the Strava API. While experimenting with $http.get, I realized that separating the logic into a dedicated service would be more organized, allowing my controller to simply call the serv ...

tips on launching a pre-existing react native project

Trying to run a project downloaded from someone else can be quite challenging. I encountered some issues where the project just wouldn't start, and now I'm completely stuck. Can anyone help me out? https://github.com/sunlight3d/react_native_v0.4 ...

What is the best way to format a condensed script into a single line?

There are times when the script in the web browser is packed into one line like function a(b){if(c==1){}else{}}. I have attempted to locate something that would display it in a more normal format. function a(b) { if(c==1) { } else { } } Howev ...

Having trouble displaying image using absolute path in Express

Currently, I am developing a NodeJS application and have encountered an issue with a div element that has a background-image set in an external CSS file. Surprisingly, the CSS file functions perfectly when tested independently, and the background image dis ...

Create a Discord.js bot that automatically deletes any URLs that are posted in the server

Seeking advice on how to have my bot delete any URLs posted by members. I am unsure of how to accurately detect when a URL has been shared, especially since they can begin with https, www, or some other format entirely. Any insights would be greatly apprec ...

What is the reason for index always being not equal to 0?

<script> var index = 0; $.getJSON("./data/data.json", function(json) { $.each(json, function(data) { var html = ""; if(index == 0) { console.log(index + " fir ...

Cross domain widget ajax request

Our company offers a widget for clients to add to their websites. This widget requires a call to our website to validate user-entered data. However, due to domain restrictions, making ajax calls from the client's website to ours is not permitted. Is ...

ng-tourguide component for navigating through multiple screens

Currently, I am utilizing Angular JS to develop my project. One requirement I have is to implement a tour guide that navigates through multiple pages and displays the next step upon clicking the next button. I have successfully incorporated ng-walkthrough ...

How can I ensure that my user responses are case-insensitive?

Currently, I'm facing a roadblock in my coding journey. I am trying to modify my code so that user responses are not case sensitive when compared for correctness. Can anyone offer some advice on how to achieve this? Check out the code snippet below: ...

Tips for integrating AudioControl with Phonegap

I couldn't find a suitable plugin, so I decided to create my own. My goal is to activate silent mode using a JavaScript command, however, I am encountering an error with the undefined method getSystemService. It seems like there may be a problem with ...

Is there a way to make an HTML link target the same as JavaScript window.opener?

Within my project, the main page is where users log in and access the primary tables. Additionally, there are numerous supplementary pages that open in separate windows. Once the login session times out, it is essential to restrict user access to any cont ...

Troubleshooting CodeIgniter's AJAX call functionality issue

I have been attempting to test AJAX functionality within CodeIgniter, but unfortunately, I haven't had any success so far. Can someone please point out where I might be making a mistake? Below is my test_page.php: <!DOCTYPE html> <head> ...