How can I prevent div duplication when working with ui-router?

I created a basic demonstration to get familiar with ui router.

Unfortunately, I encountered an issue of duplicated views when utilizing ui router.

Below is the snippet of the stateProvider section:

app.config(function($stateProvider,$urlRouterProvider){
    $urlRouterProvider.otherwise('/baseView');

    $stateProvider
        .state('baseView',{
            url:"/baseView",
            templateUrl:"baseView.html"
        })

        .state('baseView.empty',{
            abstract: true,
            views:{
                "navBar":{
                    templateUrl:"sideBar.html",
                    controller: "sideCtrl"
                },
                "123":{
                  templateUrl:"content.html"
        }
            }
        })

        .state('baseView.empty.content1',{
            url:'/content1',
            templateUrl:"content1.html"
        })

        .state('baseView.empty.content2',{
            url:'/content2',
            templateUrl:"content2.html"
        })
})

Here's the plunker link for reference: http://plnkr.co/edit/Rm0Q50GX2GYvqyKnzkKz?p=preview

The duplication issue becomes evident in the plunker preview.

Upon inspection, it appears that the problem lies within the state provider segment as removing it eliminates the duplicate view...

Answer №1

The issue does not stem from state definitions. The problem lies in the fact that you have loaded angular.js and ui-router.js twice, resulting in the instantiation of the same thing twice. Removing one of the references should resolve the issue.

Access Forked Plunkr Here

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

The Failure of window.pushState in HTML 5 History

Looking to implement ajax loading for updating center content and URL without refreshing the page. Everything seems to be working fine except for the history management. It appears that window.pushState is not properly recording URLs or the popstate even ...

Although CORS is enabled, I am still encountering a CORS error

I'm attempting to retrieve a JSON object from an API where the developers have recently enabled CORS. However, I'm still encountering the following error message: XMLHttpRequest cannot load http://example.com/data/action/getGame/9788578457657. ...

The dimensions of the box are not predetermined by the size of the photo

I'm attempting to develop a photo gallery that emulates the style of (using the Unsplash API -> ) However, the size of the container box does not adjust properly with the photos. https://i.sstatic.net/1PAQF.jpg <div className="imageGrid_ ...

Using JQuery to create interactive dropdown menus with dynamic options

I am exploring the possibility of dynamically updating the choices available in an HTML dropdown menu based on the selection made by a user - consider this sample JSON data: series: [ {name: 'Company X', product: 'X1'}, {name: 'Co ...

Creating Dynamic Menus in Angular

My current setup is as follows: I am using a Dynamo DB table with 3 items, each representing a link in a menu. To fetch and display this data, I have set up a Lambda function which scans the table and sends a JSON response through an API gateway. Within ...

Utilizing PHP and AJAX to Extract Information from a MySQL Database

My goal is to fetch data from a MySQL database hosted on a webserver and display it in an HTML table. I've been following an example on W3Schools, but I'm facing issues retrieving the data successfully. Here is the source code: (HTML) <html& ...

How can Angular.js directives help display various nested data structures?

Is there an Angular.js directive available for displaying nested JSON data dynamically as a view without prior knowledge of the structure? Let's say we have the following JSON resource at a REST endpoint /api/orgranisations/:organisation_id/: { ...

Creating a custom JavaScript clock based on stored database values

I am looking to create an analog clock using JavaScript. I have both working hours and off hours stored in a database. My goal is to display working hours in one color and off hours in another color on the clock. How can I achieve this? The database prov ...

The challenges of using Three.JS and Blazor: Solving Black Canvas and Console Errors in WebGL

Exploring the world of Blazor web assembly, I embarked on a project to harness the power of JSInterop with Three.JS to draw lines. Following the guidelines provided in their tutorials available Here, I diligently installed Three.JS using npm and webpack, w ...

Guide on implementing two submission options in an HTML form using JavaScript

Currently, I am working on a form that includes two buttons for saving inputted data to different locations. However, I am facing an issue with the functionality of the form when it comes to submitting the data. Since only one submit function can be activa ...

Leveraging URL parameters in Express.js Routes

Within my routes directory for a node and Express.js web application, the code snippet below is causing a problem: var router = express.Router(); router.get(htmlExt('index/:fileName'), function(req, res){ console.log(req.params.fileName); }); ...

Tips for correcting the `/Date(xxxxxxxxxxxxx)/` formatting issue in asp.net mvc

As a programming novice, I am trying to display data from my database server on the web using a datatable in asp.net mvc. After following a tutorial video on YouTube, I encountered an issue where the date and time columns in my table are displaying as /Dat ...

StorageLimit: A new condition implemented to avoid saving repetitive values in the localStorage

Is there a way to store the text of an li element as a localStorage value only once when clicked? If it already exists in localStorage, a second click should have no effect other than triggering an alert. I'm currently using an if statement inside a ...

Select the correct nested div with the same name by clicking on it

My problem involves nested div elements with the same class. For example, I have a Panel inside another Panel. However, when I click on the inner panel, it is actually the outer panel that triggers the $(".panel").click function. What I need is for the ...

jsonwebtoken does not fetch a token

I've been working on a user registration system using nodejs and sequelize. So far, I've successfully implemented the login and register functionalities. However, I am encountering an issue with getting the token after a successful login. Despit ...

Here's a method to extract dates from today to the next 15 days and exclude weekends -Saturday and Sunday

Is there a way to generate an array of dates starting from today and spanning the next 15 days, excluding Saturdays and Sundays? For example, if today is 4/5/22, the desired array would look like ['4/5/22', '5/5/22', '6/5/22' ...

Show a Pair of Images Upon Submission Utilizing Ajax

Imagine having two separate div containers displayed as shown below: What I achieved was clicking the submit button would upload the image to the designated area. However, my goal is for a single click on the button to load the image in both containers. ...

Generate an array consisting of characters within a designated range

I recently came across some Ruby code that caught my attention: puts ('A'..'Z').to_a.join(',') The output was: A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z I'm curious if there is a similar way to achieve this ...

Enabling communication between directives using controller API in AngularJS

Interaction Between Child and Parent Directives While the code below generally functions properly, there is an issue that arises when the template line in the parent directive (parentD) is uncommented: .directive('parentD', ['$window', ...

How do I prevent a specific word from being removed in a contenteditable div using JavaScript?

Attempting to create a terminal-like experience in JS, I am looking to generate the word 'current source, current location' (e.g., admin@ubuntuTLS~$: ~/Desktop) at the beginning which cannot be removed. Also, I want to prevent the caret from bein ...