The <base href> element leads to the display of an "[$rootScope:infdig] " error

I am attempting to pass two parameters from first.html to second.html through the URL and retrieve the values in second.html using routeParams. The base tag has been set as

<base href="file:///D:/abhilash/node/angapp/"/>
and upon clicking a button, the parameters in the input textboxes should be passed through the URL.

Contents of first.html:

   <!DOCTYPE html>
<html ng-app="myapp">
<head>
    <title></title>
    <base href="file:///D:/abhilash/node/angapp/"/>

</head>
<body>
<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-route.js"></script>
<script type="text/javascript" src="controller.js"></script>

<div ng-controller="firstController">
    First name:<input type="text" ng-model="firstName"><br>
    Last name:<input type="" ng-model="lastName"><br>
    <input type="button" ng-click="loadView()" value="submit" name="">

</div>
</body>
</html>

Contents of second.html:

    <!DOCTYPE html>
<html ng-app="myapp">
<head>
    <title></title>
<base href="file:///D:/abhilash/node/angapp/"/>
</head>
<body>

<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-route.js"></script>
<script type="text/javascript" src="controller.js"></script>

<div ng-controller="secondController">
 {{firstName}}

</div>

</body>
</html>

Controller script:

(function(){
var app = angular.module('myapp', ['ngRoute']);

app.config(function($routeProvider,$locationProvider){

    $routeProvider.when('/first',{
        templateUrl:'/first.html',
        controller: 'firstController'
    })
    .when('/second/:firstName/:lastName',{
        templateUrl:'/second.html',
        controller:'secondController'
    })
    .otherwise({
        redirectTo:'/first'
    })
    $locationProvider.html5Mode(true);
})

app.controller('firstController',function($scope,$location){
        $scope.firstName="";
        $scope.lastName="";
        $scope.loadView = function()
        {
            $location.path('second/'+$scope.firstName +"/" +$scope.lastName);
            console.log($location.url());
        }
    })
    .controller('secondController',function($scope,$routeParams){
        $scope.firstName = $routeParams.firstName;
        $scope.lastName = $routeParams.lastName;
    })
}());

Answer №1

Take a look at this code snippet here If your application is being deployed in the root context (for example, ), make sure to set the base URL to /:

<head>
  <base href="/">
  ...
</head>

If your application is being deployed in a sub-context (such as ), set the base URL to the URL of that sub-context:

<head>
  <base href="/subapp/">
  ...
</head>

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

Encountering issues with creating a session in Selenium/webdriver while utilizing Safari 12

Ever since making the update to Safari 12, my automated scripts have been encountering a new error: SessionNotCreatedError: Request body does not contain required parameter 'capabilities'. (Interestingly, this error is exclusive to Safari and d ...

What is the reason behind the caret in the input being set at the beginning when using focus() without a timeout?

I am currently exploring the implementation of keyboard navigation between multiple input fields using VueJs. Here is how the template is set up... <div v-for="(note, index) in notes" :key="index" ref="notex" cla ...

Struggling with React integration of AdminLTE3 sidebar treeview?

I have a requirement to create a React sidebar with a category 'Staff' that, when clicked, reveals three subordinate categories. Below is the code snippet: import React, { Component } from "react"; export default class Sidebar extends Componen ...

Integrating AngularJS with Vaadin

Having previously integrated jquery with Vaadin in custom components multiple times, I am curious to see an example of AngularJS integration with Vaadin. Furthermore, I would like to confirm if AngularJS is compatible and functioning properly with IE9. ...

Exploring the capabilities of setState within conditional statements in React Native

Hello there! Currently, I am attempting to export exportTest to a separate js file in order to re-render. Here is my approach: import React, { useState } from 'react'; import { StyleSheet, View } from 'react-native'; var n; export var ...

Is there a way for me to extract a smaller segment from an ID label?

I am working on a web development project and I have a set of buttons within a specific section. Each button has an id in the format of #balls-left-n, where n ranges from 1 to 15. My goal is that when a user clicks on one of these buttons, I want to extra ...

Creating a dynamic hyperlink variable that updates based on user input

I am attempting to create a dynamic mailto: link that changes based on user input from a text field and button click. I have successfully achieved this without using the href attribute, but I am encountering issues when trying to set it with the href attr ...

The grid component fails to display data from the store in ext js version 6.0.0

While studying the book 'Mastering Ext Js', I encountered a problem with the Grid Panel not loading data from the store. Despite checking the Json format server, everything seems to be fine and there are no errors in the console. Below is my mod ...

The Angular7 counterpart of the C# attribute decorator

I'm working with an API method that has an Authorize attribute to verify permissions. [Authorize(ReadIndexes)] public async Task<IActionResult> GetIndexes () { ... } Is there a similar way in Angular to implement permission checks so the API ...

Is one-way data binding possible in Angular?

I'm inquiring about one-way data binding with AngularJS. Imagine we have two input boxes on the same page, labeled A and B. Is it possible for input A to change input B, without input B affecting input A? I am aware of Angular's bindonce featu ...

What is causing the error in this JavaScript code?

I understand that in JavaScript only function declarations are hoisted, meaning it should print 30 after executing the function sum. However, I am confused because it is saying diff is not defined. Shouldn't it have been hoisted as well? sum(10, 2 ...

When using Angular $HTTP, CORS is supported when working with application/x-www-form-urlencoded, but there is a problem with OPTIONS 404

I have successfully implemented a Node + ExpressJS with CORS setup using this middleware. However, I am facing issues when working with POST requests. Here is what works: $http.defaults.headers.post["Content-Type"] = "application/x-www-form-urlencoded"; ...

Reinitializing a form with jQuery validation inside a modal box

While utilizing jQuery Validate in a form within a jQuery dialog, I am encountering an issue. Upon closing the dialog, I aim to clear all form fields and reset any fields with error feedback displayed. Although the fields are being reset to blank as expec ...

What is the recommended data type to assign to the `CardElement` when using the `@stripe/react-stripe-js` package in TypeScript?

I'm struggling to determine the correct type to use for this import: import { CardElement } from '@stripe/react-stripe-js'; I have successfully used the types Stripe, StripeElements, and CreateTokenCardData for the stripe and elements props ...

JavaScript function trying to send a POST request to API

I'm encountering an issue when attempting to execute an API GET request using JavaScript's built-in XMLHttpRequest function. I'm perplexed by why this functionality is failing to operate properly. function getStats(username){ const request ...

What is the best way to find the average within different groups in a JavaScript Array?

I am currently working with the Angular JS framework and have a NodeJS array like this: var arr = [{"object":"Anguille","fct":"Type A","value":"2"},{"object":"Athérine"," ...

Navigating through elements of an array in Javascript

What is the best way to iterate through every element of an array in JavaScript? <script> var arrayCollection; $(function() { arrayCollection = [ {"id": "animal", "parent": "#", "text": "An ...

Strategies for capturing and incorporating Meteor.Error notifications from Meteor.Methods into a client-side database?

I am currently working on creating an error notification panel in Meteor. I have set up a client-side MongoDB, but I am encountering an issue with pushing Meteor.Error messages into that client-side database using the throwError function. Currently, the er ...

Resetting all inputs and setting them back to their original pristine state upon clicking

Today is my first day using AngularJS, taking over a project from another developer. I have a login/registration form on my interface that gets hidden once the submission is made. After the user submits the form, I want to clear the entries and restore the ...

Having trouble retrieving nested object properties within a single object when making a JSON call in React?

When making a Rails API call, I receive a single JSON object with a nested User Object and a tag list array. However, I am unable to access the nested Object. The error message "Cannot read property 'name' of undefined" appears when trying to ac ...