Is it a bug if we utilize AngularJS to retrieve data for <li><a href>?

Using AngularJs, I am able to retrieve data from a MySQL database for my navigation bar on an HTML5 page. However, there seems to be an issue with opening links in the sub menu. Below is a snippet of my code:

<div id="header-wrapper" class="wrapper">
<div ng-app="myApp" ng-controller="customersCtrl" id="header">
  <div id="logo">
    <h1><a href="index.html">Why Choose a Breeder ?</a></h1>
        <p>Quality Quarantee Knowledge</p>
  </div>
  <nav id="nav">
    <ul>
      <li class="current"><a href="index.html">Home</a></li>
      <li><a href="hollandlop.html">Holland Lops</a>
      <ul>
        <li><a href="hollandlop.html#buck" id="bucks">Bucks</a></li>
        <li><a href="hollandlop.html#doe" id="does">Does</a></li>
        <li><a href="hollandlop.html#junior" id="juniors">Junior</a></li>

      </ul>
      </li>

      <li><a href="sale-policy">For Sale</a></li>
      <li><a href="sale-policy">Article</a>
      <ul><li ng-repeat="menu in menues"><a href="{{menu.Link}}" target="_self">{{menu.Title}}</a></li></ul>
      </li>
      <li><a href="why-breeder.html#contact" id="contact">Contact us</a></li>
      </ul>
      </nav>
 </div>

https://i.sstatic.net/QVzuC.jpg

Upon further investigation, it appears that the link cannot be opened when clicking within this section of code:

<ul><li ng-repeat="menu in menues"><a href="{{menu.Link}}" target="_self">{{menu.Title}}</a></li></ul>

If I remove the ul tags, like shown below:

          <li><a href="sale-policy">For Sale</a></li>
          <li><a href="sale-policy">Article</a></li>
          <li ng-repeat="menu in menues"><a href="{{menu.Link}}" target="_self">{{menu.Title}}</a></li>

https://i.sstatic.net/ncJHN.jpg

I found that the link can be successfully opened. Could it be an issue related to the order of elements in the navigation bar? Any suggestions on what could be wrong?

Here is the relevant .js code:

var app = angular.module('myApp', []);
app.controller('customersCtrl', ['$scope','$http',function($scope, $http){
    $scope.menues = [];
    $http.get("http://www.rhosgobelrabbit.com/getUrl.php")
    .then(function (data) {$scope.menues = data.data.records;
    }, function (error) {
        alert('Error');
    });
}]);

Answer №1

To ensure proper functioning, use ng-href instead of href when working with AngularJS. Detailed information can be found in the angularJS documentation: Docs

<ul><li ng-repeat="menu in menues"><a ng-href="{{menu.Link}}" target="_self">{{menu.Title}}</a></li></ul>

If the ng- is not added before href, Angular will result in a 404 error.

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

Ways to deactivate the Bootstrap collapse feature

In my accordion FAQs, I am facing an issue where Question 1 is automatically opened when the page loads. Additionally, when I click on Question 2, it closes instead of staying open. I would like to address these problems and make sure that each question st ...

Utilizing jQuery to load HTML content into a div restricts my ability to navigate back and forth seamlessly

I am new to jquery and currently working on my first project. In my index.php file, I have included: header.html indexview.html footer.html. The indexview.html file consists of two divs - one for the menu on the left and another (div id="content") f ...

Storing POST data in MongoDB using Node.js

I'm a beginner with node.js and I'm looking to save data from an HTML form (such as username, password, email, etc.) into MongoDB. Here is the code snippet that I am using: var Schema = new mongoose.Schema({ _id : String, name: St ...

Updating website content dynamically using AJAX and URL manipulation without refreshing the page (Node.js)

How can I update the inventory without refreshing the page using both button events and URLs? I want to be able to update to a specific page based on the URL parameter (like /inventory/2) when it is passed to the route. Currently, my AJAX request works but ...

Including folders recursively using Node.js

Currently, I am in the process of setting up test automation using yarn, selenium, and node js. In the wdio.conf.js configuration file, there is a requirement to specify a specs array that contains strings representing paths to various js files for executi ...

The functionality of $location.path() seems to be malfunctioning when it comes to scroll

angular.module('example').service('myService', function myService($rootScope,$route,$http,$location) { $("#mainwindowscroll").on('scroll', function (e) { $location.path('/about&apo ...

Concealed Sub Menus Within a Vertical Navigation Bar

I've successfully created a Vertical Menu with hidden submenus, but I'm struggling to make the submenu appear on hover. Any suggestions on how to achieve this? Also, I'd like to align the text all the way to the left and remove the bullets f ...

What is the best way to prioritize the display of custom login buttons based on the last button used for login?

I have implemented 4 different login methods for my app, each with its own associated component. I am looking to rearrange the buttons based on the last used login method. I already have a function to determine the last login method. let lastSignedInMetho ...

Filled with challenges in React

Having trouble with loading loaders.css file due to an error. The module build failed because it couldn't find the 'daisyui' module, leading to a stack of require calls: F:\VS code\three js\material tailwind\Clone\ ...

Utilize the concept of nesting rows within table data cells

I'm having trouble implementing nested rows within a td element that span the full length. Here is my code: <td> <table class="table table-striped"> <tr> <td colspan="3">I am nested in a table column< ...

Submitting Input Values One by One in Codeigniter Using Ajax

Apologies for my limited English skills and being a newbie :) I am trying to update input values one by one using ajax in Codeigniter, but it's not working correctly. Only one save button (one form) is working, the others are not. Can someone please ...

Enhance your webpage with custom styling using the html() method in jQuery

Adding style to my website using the .html() method is something I'm looking to do. I've attempted this: Using jQuery: if ($('#checkbox:checked') > 0) { $("body").html(" <style> .selected{ ...

Create a JavaScript code snippet that replaces the innerHTML of the function document.getElementById with

In my limited knowledge of JavaScript, I have come across an issue with the following code: function example() { document.getElementById("example").innerHTML = "<script>document.write(example)</script>"; } Unfortunately, this code doesn&ap ...

Having trouble with the date format in the highCharts range selector?

I am encountering an issue while trying to implement the rangefilter feature with HighCharts. The start and end dates are appearing incorrect, indicating that my date is not being recognized properly. My x-axis consists of unique dates as categorical valu ...

Enhancing next-auth and i18n functionality with middleware in the latest version of next.js (13) using the app

Currently, I have successfully set up next-auth in my next.js 13 project with app router, and it is functioning as expected. My next step is to incorporate internationalization into my app following the guidelines provided in the next.js documentation. How ...

How to tally items according to their status and store utilizing JavaScript?

I have a JSON array and I am looking to add a new field to each object which will represent the count of that object. The count should be based on the status, shop, and name in the ownerDetails property. How can I achieve this? The expected output is pro ...

How can I connect PHP table data with unique identifiers to JavaScript using arrays?

Allow me to clarify my question/task: 1) I currently have a PHP table that displays temperature data for a specific date and time using an API from a weather forecast. 2) The task at hand is to convert this table into a line graph using Javascript. 3) I a ...

Change the background color of numbers in an array using DOM manipulation in JavaScript

Can someone assist me with the following task: 1. Generate an array containing 10 numbers ranging from 0 to 360. 2. Display these numbers on the DOM within a chosen element. 3. Adjust the background color of each number based on its HUE value in (hue, sat ...

What's the best way to position a lone CTA at the center of the second row on a two-column layout using Elementor?

On my page, I am facing a challenge of adding a second section with a single Call to Action (CTA). The previous section on the same page consists of two CTAs placed side by side with a width set at 50% each. However, now I need to add a third CTA without i ...

Using AngularJS to render data in HTML

Is there a way to display HTML from a value variable in AngularJS similar to how @Html.Raw() works in ASP.NET? In the current scenario, only text with tags is being displayed. JS: var app = angular.module('Demo', []); app.controller('TestC ...