The primary controller in AngularJS

I am currently facing an issue where I am unable to load a page to its home page. When I first load the page, it redirects me to app/index.html. Is there a way to redirect the page to app/home instead?

Below is my app.js code:

(function () {

"use strict";
// Starting a new application, a module in Angular
// Application name 
// Dependencies are passed through an array
angular.module('MovieApp', ['ngRoute']).config(
    [
        '$routeProvider', function ($routeProvider) {
            $routeProvider.
                when('/home', {
                    templateUrl : 'js/partials/home.html',
                }).
                when('/category', {
                    templateUrl : 'js/partials/category-list.html',
                    controller : 'CategoryController'
                }).
                when('/category/:categoryid', {
                    templateUrl : 'js/partials/film-list.html',
                    controller : 'MovieController'
                }).
                when('/actor/:filmid', {
                    templateUrl : 'js/partials/actor-list.html',
                    controller : 'ActorController'
                }).
                when('/movieList', {
                    templateUrl : 'js/partials/allmovie-list.html',
                    controller : 'AllMovieController'
                }).
                when('/search', {
                    templateUrl : 'js/partials/search.html',
                    controller : 'SearchController'
                    // controllerAs: 'movies'
                }).
                when('/login', {
                    templateUrl : 'js/partials/login.html',
                    controller : 'LoginController'
                    // controllerAs: 'movies'
                }).
                when('/logout', {
                    templateUrl : 'js/partials/login.html',
                    controller : 'LogoutController'
                    // controllerAs: 'movies'
                }).
                when('/filmDetails/:filmid', {
                    templateUrl : 'js/partials/note.html',
                    controller : 'FilmDetailController'
                }).
                otherwise({
                    redirectTo : '/'
                });
        } 
    ]
);  // end of config method 
}());   // end of IIFE

Here is my index.html page:

<header>
  <div id="header" data-ng-controller="IndexController">

    <ul>
      <li><a href="#/home">Home</a></li>
      <li><a href="#/movieList">Movie List</a></li>
      <li><a href="#/category">Category</a></li>
      <li><a href="#/search">Search</a></li>
      <li ng-hide="loginEnabled"><a href="#/login" >Login</a></li>
      <li ng-hide="logoutEnabled"><a href="#/logout">Logout</a></li>
    </ul>
          <h2>{{Message}}</h2>

  </div>
</header>

<div id="content">
  <!-- <h1>Welcome to FMS Website</h1> -->
  <article data-ng-controller="CategoryController"></article></br></br>
  <article data-ng-view></article>
</div>

If anyone can provide assistance on this matter, I would greatly appreciate it. Thank you.

Answer №1

Have you attempted this?

when('/', {
       templateUrl : 'js/partials/home.html',
 })

.

Answer №2

Revise the following to redirect to your main page:

redirect({
            to : '/main'
          });

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

Utilizing React JS to dynamically incorporate form values into objects

I have an array of objects where I need to add a key value State : const [row, setRow] = useState([{ nameofthework: "", schedulerefNo: "", unitprice: "", qty: "", uom: "", gst: "", total: "& ...

What is the best way to pass an array from a controller to an AJAX function in Laravel 4?

Hi there, I'm currently using Laravel 4 and I'm still a beginner in this field. I am trying to retrieve an array of data from my controller to pass it to my AJAX function for assisting me in creating my chart. Here is the code snippet from my co ...

Leveraging the Google Feed API using jQuery's AJAX functionality

Currently, I am attempting to utilize Google's Feed API in order to load an RSS feed that returns a JSON string. (For more information, please refer to: https://developers.google.com/feed/). Despite this, my approach involves using jQuery's AJ ...

Can all VM scripts be blackboxed in the chrome debugger?

Currently, I am facing a challenge while debugging a complex module in my angular application. I have added a breakpoint at the beginning of a specific method with the hope of tracing it to identify the error point. However, every time I try to follow it, ...

Updating parent scope data from within a directive without relying on isolated scope bindings

What is the best method for passing data back to the parent scope in AngularJS without using isolated scopes? Imagine I have a directive called x, and I want to access its value named a. The desired syntax would be: <x a="some.obj.myA"></x> c ...

Utilize AngularJS to enable Semantic UI component without the need for jQuery

Currently, I am in the process of developing a website using AngularJS and Semantic UI. While everything seems to be working well with the CSS components, I have encountered an issue when trying to activate the JavaScript components. For instance, I typic ...

What are some ways to enhance the loading time of my PHP-powered website?

Having troubles with my PHP-driven website that showcases real-time stock market data due to slow loading speeds. The site utilizes PHP for scraping financial information from external sources and presenting it on the front end. However, the performance is ...

What's causing the unexpected rendering outcome in Three.js?

Here is a mesh created in Blender: https://i.sstatic.net/KBGM5.jpg Upon loading it into Three.js, I am seeing this result: https://i.sstatic.net/PCNQ8.jpg I have exported it to .obj format and ensured all faces are triangulated. I am not sure why this is ...

Validate the checkbox with Vuelidate only when the specified property is set to true

I have a website login form where users may need to check a specific checkbox before logging in. Here is part of the Vue component code that handles this functionality: <script setup lang="ts"> import {ref, defineProps} from 'vue&a ...

What is the process for running .js files on my browser from my local machine?

Hi there! I'm trying to figure out how I can create a JavaScript game in TextMate on my Mac. I want to have a regular .js file, then open it and run it in Chrome so that whatever I have coded - for example, "Hello World!" - will display in the browser ...

Tips for styling a React JS component class

I am attempting to write inline CSS for a React JS component called Login, but I keep encountering an error. What could be causing this issue? Could you provide guidance on the correct way to implement in-line component CSS? import React, {Component} from ...

AngularJS HTTP POST request encountering issue with success function not functioning as expected

I am currently working on implementing a basic HTTP post request to insert data into my database. The following pages are involved: register.php contains the registration form. maincons.js houses the application controllers. sqlregister.php include ...

What is the best way to retrieve an array element from outside a function?

Is there a way to access the distance and pos elements outside of the function in this code snippet? navigator.geolocation.getCurrentPosition(function(position) { var pos = { lat: position.coords.latitude, lng: position.coords.longit ...

Tips for Embedding External JavaScript and URLs in Joomla Protostar Template

I'm interested in incorporating a hamburger menu into my Joomla protostar template, similar to the one featured on this URL: ['https://codepen.io/PaulVanO/pen/GgGeyE'] This will provide me with a fullscreen hamburger menu for both desktop ...

React - Updating the Color of a Specific Div within a Map Component

Currently, I am delving into React and Material UI and facing an issue with changing the background color of a clicked div. As it stands, all the divs are being affected when one is clicked. My goal is to have the background color transition from white to ...

Using JSON object as an argument in React functional component

Currently, I'm trying to assign a JSON object to a const variable. I've been successful with using vars in the past, like so: {this.props.user.map(function(user){... However, when it comes to stateless consts, I'm encountering some confusi ...

Expand the width of the image gradually until it reaches its initial size within a flexible DIV container

I am working with a <div> container that occupies 80% of the screen on a responsive page. Within this <div>, I am attempting to display an image that is sized at 400 x 400 pixels. My objective: As the screen width increases: The <div> ...

Customize your Wordpress site with a JQuery load more button specifically designed for custom post types

I'm currently working on adding a "load more" button to my WordPress website in order to load my custom post types. I've managed to successfully make it load the posts, but I'm facing an issue where each time I load more posts, it replaces t ...

Vue Js and form-data Event: A deeper look into handling form

Hey there #Vue.js2 I'm facing an issue while trying to create a function that is called within a form submit event. This particular function needs both the EVENT and ID as parameters. The problem arises when I call this function, as I am unable to spe ...

Different methods for adjusting CSS properties that are dependent on other components

I'm currently working on a website using the React library. While I have made progress, I am stuck on how to adjust CSS properties that are interdependent. Specifically, I need help removing the blur filter from my text area .mirror-container which is ...