The AngularJS routing template fails to load

I am currently working on the app.js file:

'use strict';

var app = angular.module('app', [
    'auth0',
    'angular-storage',
    'angular-jwt',
    'ui.router',
    'Environment',
    'Api',
    'Profile'

]);


app.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('main', {
            url: '/main',
            templateUrl: 'js/modules/App/views/frontpage.html'
        })
        .state('login', {
            url: '/login',
            templateUrl: 'js/modules/User/views/login.html',
            controller: 'LoginCtrl'
        });

    $urlRouterProvider
        .otherwise('/main');
}]);


app.config(['authProvider', '$httpProvider', '$locationProvider', 'jwtInterceptorProvider',
    function myAppConfig(authProvider, $httpProvider, $locationProvider, jwtInterceptorProvider) {
        authProvider.init({
            domain: 'marcrasmussen.eu.auth0.com',
            clientID: 'hphpe4JiceMW8FSA02CN7yOYl5fUaULe',
            loginUrl: '/login'
        });

        authProvider.on('loginSuccess', ['$location', 'profilePromise', 'idToken', 'store',
            function ($location, profilePromise, idToken, store) {

                console.log("Login Success");
                profilePromise.then(function (profile) {
                    store.set('profile', profile);
                    store.set('token', idToken);
                });

                $location.path('/');
            }]);

//Called when login fails
        authProvider.on('loginFailure', function () {
            alert("Error");
        });

        //Angular HTTP Interceptor function
        jwtInterceptorProvider.tokenGetter = ['store', function (store) {
            return store.get('token');
        }];
//Push interceptor function to $httpProvider's interceptors
        $httpProvider.interceptors.push('jwtInterceptor');

    }]);

app.run(['auth', function (auth) {
    // This hooks all auth events to check everything as soon as the app starts
    auth.hookEvents();
}]);

Let me introduce you to the profile.js file:

angular.module('Profile', [])
.config(['$stateProvider', '$urlRouterProvider', function ($stateProvider, $urlRouterProvider) {
    $stateProvider
        .state('profile', {
            abstract: true,
            url: '/profile'
        })
        .state('profile.index', {
            url: '/index',
            templateUrl: 'js/modules/Profile/views/viewProfile.html'
        })
}]);

Included in my index.html, the files are structured as follows:

<script src="js/modules/Profile/lib/profile.js"></script>
<script src="js/modules/App/lib/app.js"></script>
<script src="js/modules/App/directives/login/login.js"></script>

Lastly, I have set up my view port as follows:

<div class="main" ui-view>

</div>

Currently, my application initiates on the route /main and successfully renders the content of frontpage.html.

However, upon navigating to profile.index or /profile/index, no errors appear in the console, and the HTML from the template file

js/modules/Profile/views/viewProfile.html
is not displayed.

If anybody could assist me in understanding why this issue is occurring and what mistakes I may be making, it would be greatly appreciated.

Answer №1

It seems like the problem could be related to your abstract state configuration. Make sure you have defined a template or templateUrl for this state. Remember that the template for an abstract state must include a ui-view directive to allow its children to be displayed.

For more information, check out: https://github.com/angular-ui/ui-router/wiki/nested-states-%26-nested-views#abstract-state-usage-examples

You might need to set up something similar to the following:


    .state('profile', {
        abstract: true,
        url: '/profile',
        template: '<ui-view />
    })

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

Deeply nested .map function to update state value

The current state value const [settings, setSettings] = useContext(SettingsContext) Utilizing the .map method on the settings state {settings[categoryIndex]?.config?.map((item: ConfigItem, index: number) => ...

Having trouble getting an Angular directive to bind a click event to an external element?

I've been working on creating a unique custom event for toggling with Angular. The directive I'm using is called toggleable. It may sound simple at first, but the tricky part is that I want to be able to use any button or link on the page for to ...

Sorting method in Ext JS 6.2.0 using mode

Seeking clarification on the sort([field],[direction],[mode]) method in Ext JS 6.2.0. Can someone explain the distinction between append, prepend, replace, and multi as mentioned in the documentation available at this link? I am unable to find a clear expl ...

Adding the highcharts-more.src.js file to an Angular 2 project: A step-by-step guide

I have linked highcharts-more to the system variable: 'highcharts-more': 'node_modules/highcharts/highcharts-more.src.js' But I keep getting an error message saying: Error in dev/process/templates/detail.template.html:40:33 ORIGINAL ...

Adding npm packages to your Vue.js application

My Vue app is structured like this (auto created by vue init webpack myProject): index.html components/ -main.js -App.vue I am trying to include npm packages, such as https://github.com/ACollectionOfAtoms/atomic-bohr-model. Following the instructions, I ...

The process of updating the value of an element in local storage with JavaScript

Most of the time we have an object stored in our localStorage. let car = { brand: "Tesla", model: "Model S" }; localStorage.setItem("car", JSON.stringify(car)); I am now eager to update the value of "model". How do I go about achieving this u ...

Exploring Elasticsearch with Ajax Query Syntax

Attempting to send a post request via AJAX to my Elasticsearch index but encountering some issues. Here's the cURL result: [~]$ curl -XGET 'http://localhost:9200/firebase/_search?q=song:i%20am%20in' {"took":172,"timed_out":false,"_shards": ...

Can anyone recommend a speedy sorting algorithm for an extensive list of objects in JavaScript?

Struggling to organize a large array of 2000 elements in ReactJS using JavaScript. The array includes: data = [ { index: 0, id: "404449", product_name: "ette", brand_name: "Dyrberg/Kern", base_pri ...

What are some ways to optimize Ajax requests for improved speed when multiple identical requests are made on a single webpage?

When the webpage is loaded, a block is dynamically created using an Ajax call to retrieve data from another page. This structure is then populated and added to a specific DOM element. However, multiple Ajax calls during page loads are causing delays. Is ...

Utilizing Angular to apply multiple ng-repeat directives with multiple filters

I am working on a project that involves multiple ng-repeat lists with several filters. Currently, I am using (ex:A.value) if (ex:B.value), but I would like to implement multiple filters. The filters I want to incorporate are recommend_search, skill_searc ...

Identifying Flash content in a unique way

In my dynamic page (let's call it myFlashContainer.jsp), the Flash content changes based on the link that is clicked. The code responsible for rendering the Flash looks like this: <object height="100%" align="l" width="100%" id="player" codebase= ...

JavaScript Language Conversion Templating

I'm currently revamping the frontend for Facebook's internationalization XFBML tag, which has been nonfunctional for a while. I'm almost done with the updates but I have hit a roadblock: swapping out tokenized translations without losing dat ...

Tips on moving information from one form to another after referencing the original page using Javascript and HTML

Imagine this scenario: A page with three text fields, each with default values. There is also a hyperlink that performs a database lookup and returns parameters to the same page where the hyperlink was clicked. The goal is for the text boxes to be automa ...

Error in AngularJS when passing object to modal dialog

I'm facing a challenge with an AngularJS application I'm developing. It involves displaying a list of contacts, each accompanied by a button that triggers a modal containing a form for editing the contact information. The issue arises when attemp ...

Is there a resource available that can help me create a jquery/ajax image slider/carousel similar to this?

One thing that really caught my eye is how cnn.com has implemented this feature. I think it would be a great addition to the website I'm currently working on. I particularly like the page numbering, as well as the first, previous, next, and last butto ...

Executing a directive function from an AngularJS controller

I am facing a challenge with integrating my controller and directive. In my controller, I have the following code snippet: .controller('MyCtrl', ['$scope', '$rootScope', 'restService', function ($scope, $rootSc ...

Performing an axios request using form data in a React JS application

I am trying to figure out how to use axios in react js to make a cURL request that is currently working. Here is the cURL request: curl -k --request GET "BASE_URL_SERVER/sendText" --form "user_id='uidxxxx'" --form "sign_id=" Every time I try to ...

The date range picker displays the previous arrow but not the next arrow

I am currently using the DateRangePicker tool and for some reason, I am not seeing the arrow that should appear on the right side. I have double-checked my configuration but can't seem to figure out what is causing this issue. In the image attached, ...

What is the procedure for generating a mouse event for clicking a tab in Selenium WebDriver?

As I work with Selenium WebDriver and Java, there is a tab named PR Per Product. Under the PR Reports tab, there are multiple tabs. In the PR tab, I used: WebElement menuHoverLink = driver.findElement(By.id("ext-pr")); actions.moveToElement(menuHoverLink) ...

When you include ng-href in a button using AngularJS, it causes a shift in the alignment of the text within the button

Recently, I've been delving into Angularjs with angular-material and encountered a slight issue with ng-href. I created a Toolbar at the top of my webpage, but the moment I include the "ng-href" attribute to a button, the text inside the Button loses ...