Creating links to other partials in AngularJS is a common task that can be achieved with

Creating a simple single page application with multiple partial pages in MVC5 has been a challenge. I have set up route configurations and controllers, but unfortunately, the links are not working as expected. When clicking on a link, instead of navigating to the correct URL, an extra '#' character is added to the address.

For example, when clicking on a link from this route: http://localhost:33087/CrudDemoApp.html#!/ it unexpectedly redirects to http://localhost:33087/CrudDemoApp.html#!/#Test rather than the desired URL which should be http://localhost:33087/CrudDemoApp.html#!/Test without the '#'. However, manually entering the correct URL in the address bar works fine.

How can I remove this extra '#' from my links' URLs?

Below is my app and route configuration:

var app2 = angular.module('customersApp', ['ngRoute']);

app2.config(['$routeProvider', function ($routeProvider) {

    $routeProvider.when('/', {
        controller: 'customersController',
        templateUrl: '/Partials/customers.html'
    }).
    when('/Test', {
        controller: 'customersController',
        templateUrl: '/Partials/Test.html'
    })


  .otherwise({ redirectTo: '/' });

}]);

I have structured the container in my HTML like this:

<!DOCTYPE html>
<html>
<head>
    <title>Crud</title>
    <meta charset="utf-8" />
    <script src="Scripts/angular.min.js"></script>
    <script src="Scripts/angular-route.min.js"></script>
    <script src="Scripts/Ang/app.js"></script>
    <script src="Scripts/Ang/controllers.js"></script>
</head>
<body ng-app="customersApp">
<a href="#Test" >TestLink</a> //How to set this links href??
<ng-view>

</ng-view>
</body>
</html>

Answer №1

Great job on your code!

Could you let me know the specific versions of angular.js and angular.route.js that you are utilizing? Based on my assessment, it appears that you have employed angular js version 1.6.

I would recommend using angular.min.js version v1.5.11 and angular.route.js v1.4.1 for optimum performance.

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 encountered during Next.js project build: Entry point specified for implicit type library 'build'

While working on my nextjs project, I encountered the following error: Type error: Cannot find type definition file for 'build'. The file is in the program because: Entry point for implicit type library 'build' Can someone guide ...

Using TypeScript, Electron can easily share a constants file between both main and renderer processes

Can Electron with Typescript share a constants.ts file between the main and renderer processes? Folder Structure: src/ main main.ts renderer renderer.ts shared constants.ts //constants.ts export const constants= { foo: '123' bar ...

New to Django - Seeking assistance with concealing sections of a dynamically generated table

I am working on a dynamic table where I need to show or hide certain parts based on the state of corresponding checkboxes. When a checkbox is unchecked, I want to hide the specific section of the table with the class "newtable" for that row only. Each row ...

What is the reason for being unable to remove the event listener from a sibling element?

function show1() { console.log("ok1"); document.getElementById("a2").removeEventListener("click", delegate); } function show2() { console.log("ok2"); } function show3() { console.log("ok3"); } function delegate(event) { var flag = event.target ...

The type 'undefined' cannot be assigned to the type 'string | Buffer | { key: string | Buffer; passphrase: string; } | GetPublicKeyOrSecret'

Verification Code for JWT This function is used to verify a jwt using typescript. public verify( token: string, secretOrPublicKey?: string | Buffer, options?: jwt.VerifyOptions ): Promise<object | string> { if (!secretOrPublicKey) { ...

sending an array from JavaScript to a Django view

Currently, I am working with django and have a search results page that requires filtering by category using ajax (jquery) requests. The filter bar is located on the side of the page, and once a user selects specific categories and hits submit, the corresp ...

When modifying the data, series, or labels in Angular-Charts bar chart, the updates do not seem to reflect properly

Looking to implement a dynamic drilldown bar chart using the code found at this link: I've set up an object containing a primary chart, list of drilldown charts, and a temporary chart. The directive in the template displays the data, series, and lab ...

Error in Angular2: Internet Explorer 11 is having trouble accessing the property 'apply' because it is either undefined or null

After upgrading my angular2 packages to the latest versions, I encountered the following error: @angular/common": "^2.3.1 @angular/compiler": "^2.3.1 @angular/core": "^2.3.1 @angular/forms": "^2.3.1 @angular/http": "^2.3.1 @angular/platform-browser": ...

Ways to retrieve the value of a specific key within an object nested within another object

Suppose I have a variable named x with the following structure: x = { choice1: { choice: { name: "choice1", text: "abc", key: "key1" } isChecked: true }, choice2: { choice: { name ...

The tooltip chart is not displaying all of its data

I create a dynamic tooltip with a custom chart inside of it. tooltip: { borderRadius: 15, borderWidth: 0, shadow: false, enabled: true, backgroundColor: 'none', useHTML: true, shared: true, formatter: function() { ...

How can I implement jQuery autocomplete with customized settings?

In my Drupal project, I am looking to implement jQuery's auto complete feature to search for nodes based on their titles. I am having trouble finding examples that align with my specific requirements: The URL structure should be: /api/node/title/{wh ...

encountering a glitch while using console.log(util.format

Let me start by saying that I am fairly new to working with node.js. A friend of mine assisted me in writing the code snippet below. I have successfully installed the necessary packages search-google-geocode, csv-parser, fs, util, and async using npm. H ...

Enhance your coding experience with code completion and autocomplete in Angular/Typescript using ATOM within

Is it possible to have Codecompletion / Autocomplete in Atom similar to Webstorm? Currently I am getting familiar with TypeScript and really enjoying it, but the lack of Codecompletion support for my HTML files in Atom is quite frustrating. Having this f ...

"Combining JSON, JavaScript, and HTML for dynamic web development

I am a junior computer programmer facing challenges with our JSON project. The objective is to store an object in local storage, but my HTML and JS code are not working as intended. It seems like nothing happens at all. Any suggestions or feedback would ...

Executing Array.prototype.filter() results in an empty array being returned

I have a list of jQuery elements that I collected using the .siblings() method, and now I am trying to filter them. Here is the HTML code: <div> <div> <label for="username">Username</label> <input class="form ...

Why am I not receiving recommendations for the data types of a function parameter when there are multiple variations available?

I'm currently navigating a JavaScript codebase that utilizes Sequelize models with documented types specified in TypeScript declaration files (.d.ts). Within my code, I am utilizing model.update() to modify certain properties on the object: To replic ...

I recently developed a T3 stack project and am currently attempting to configure a next JS middleware, however, I am encountering issues with it not triggering as expected

Having issues with my T3 stack app where the next js middleware is not triggering. I've placed a middelware.ts file in the root directory. middleware.ts // middleware.ts import { NextResponse } from "next/server"; import type { NextRequest ...

Disable the meta tags in Zurb Foundation 5

I have searched extensively online but haven't been able to find a solution for this issue. How can I disable these zurb foundation 5 meta tags in the <head>: <meta class="foundation-mq-small"> <meta class="foundation-mq-small-only"> ...

retrieving particular information from within a Firebase array

My Firebase document contains a list with various properties such as name and imgUrl. Currently, I am facing an issue with extracting only the "name:" information from the list in Firebase Cloud Firestore so that I can determine how many times a specific n ...

Event queuing in Angular and PhoneGap allows for seamless handling of asynchronous

Here is my code snippet: app.factory('contacts', function ($rootScope, $q, cordovaReady) { return { find: cordovaReady(function (filter) { var deferred = $q.defer(); var options = new ContactFindOptions(); ...