I am struggling to locate the template for my Angular UI modal

I recently developed an app and tried using UI modal, but encountered an issue where the modal function couldn't locate the HTML template. I was able to log messages inside the function but was unable to open a modal view.

 var app = angular.module('myApp', [
        'angularUtils.directives.dirPagination',

    'ui.bootstrap'
    ]);


    app.controller('galleryCtrl', ['$scope', '$http', function ($scope, $http) {

    }]).
    controller('ModalInstanceCtrl',['$scope','$modal',function($scope, $modalInstance){

    }]).
    directive('myGallery', function ($http,$modal) {
        return {
            restrict: 'E',
            scope: {
                feed: '@',
                search: '=?',
                resultsPerPage: "=?",
                sorting: "=?"
            },
            templateUrl: './MyGallery.tpl.html',
            link: function (scope, element, attrs) {


                scope.search = scope.search || true;
                scope.sorting = scope.sorting || true;
                scope.resultsPerPage = scope.resultsPerPage || 10;

                console.log(scope.resultsPerPage);

                scope.openModal = function() {


                    
                    var modalInstance = $modal.open({
                        templateUrl: '/views/modal.html',
                        controller: 'ModalInstanceCtrl'
                    });
                };

In the html code:

<div class="imgs">
    <ul>
        <li dir-paginate="img in imgs
        | filter:query
        | itemsPerPage: resultsPerPage.value || 10 ">
               <a href=""><img ng-src="{{img.url}}" ng-click="openModal()"></a>
        </li>
    </ul>
</div>

When trying to access the modal, this error message shows up:

 GET http://localhost:63342/views/modal.html 404 (Not Found)

Despite ensuring that the path is correct, the problem persists. Any insights on what might be causing this?

Answer №1

Double check by attempting this:

templateUrl: 'views/modal.html',

It's possible that the document root of your local server is not where you assume it to be.

By removing the initial slash, you ensure that the path is relative to the main folder of your Angular project.

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

Determining the JavaScript event source within a function's scope: A guide

Query Can we determine the origin of a function being triggered by either a user event or an async event, without having access to the original event parameter? Situation I am faced with the challenge of identifying the event source within a nested funct ...

Guide to enhancing jQuery tooltip plugin with ajax support - integrating live functionality

I am currently using a jQuery plugin from However, I am facing an issue where the plugin does not work properly when using Ajax. I would like to modify or add a function live() to address this problem. Here is the complete code: http://pastebin.com/up6KY ...

By-passing Mistakes in Iteration in JavaScript

I have been working on using Google's Feed API to fetch images from a feed within an AngularJS controller. It successfully retrieves three images, but encounters an issue when it reaches a Twitter URL, causing the script to break. I would like it to s ...

Create a unique custom spinning loader for a straightforward Vue.js application

I've set up a basic Vue project on codesandbox.io that includes vue-router and a custom spinner for loading. Spinner.vue: <template> <div class="spinner" v-show="loading"> <span class="sync" v-bind:style="[spinnerStyle, spinnerD ...

PHP-powered Countdown Timer for triggering a button's action

Hey everyone, I could use some assistance. Here's my situation - I have a database table with a column called "created_time" that stores the current system time in HH:MM AM/PM format. I want to have a button on one of my PHP pages named "Start Exam" t ...

Nesting maps in JavaScript is a powerful way to transform

I'm in the process of developing a budgeting app using React and JavaScript. At the moment, I have successfully generated a table displaying various costs. Name Budget Used $ Used % Available Food 300 300 100 0 Streaming services 600 600 100 ...

Utilizing HTML5 history instead of hash URLs to preserve the user's browsing history

Our application is a single page that dynamically loads results based on query strings. The query string format we use is as follows: ?city=Delhi&pn=1 Within the SPA, there are different sections displayed on the same page. As users navigate through ...

Creating a custom dynamic favicon and title in NextJS

Hello there! I am in the process of creating a web constructor. Currently, my application functions as follows: I verify the URL that the user is visiting (such as localhost:3000) I identify their project name within my web constructor (localhost:3000 -&g ...

Issue with Trix text editor not triggering the change event

Lately, I've been facing some difficulties in getting the tirx-change event to trigger when there are changes in the content of a trix-editor. Despite using React JS for the view, I haven't been able to identify the problem. Below is the code sni ...

Tips on how to automatically scroll a display flex div to the bottom

Traditionally, setting scrollTop of a div can be used to scroll it to the bottom, as shown in this example: http://jsfiddle.net/jPVAf/50/ However, if the div has the style display: flex, the technique mentioned above will not work. Here is an example demo ...

Correct Way to Use 'useState' in Formik's 'onSubmit' Function?

I recently encountered an issue while using Formik in my Next.js application. Specifically, I am facing a problem with the submit `Button` component, which accepts a `showSpinner` prop to control its behavior. When set to true, the button is disabled and d ...

The sorting functionality in Angular.js using the orderBy directive seems to be malfunctioning as it is not

Within this code snippet, @Model.jsonString represents a string. @model WebApplication1.Models.Car @{ ViewBag.Title = "Index"; Layout = "~/Views/Shared/_Layout.cshtml"; } <html> ... <body ng-app="myModule"> <div ng-controller="myC ...

Styled-components is not recognizing the prop `isActive` on a DOM element in React

In my code, I have an svg component that accepts props like so: import React from 'react'; export default (props) => ( <svg {...props}> <path d="M11.5 16.45l6.364-6.364" fillRule="evenodd" /> </svg> ) ...

Ways to retrieve an element from an array

I need help finding the right way to retrieve the value of the message "Meeting 9943...is not found or has expired". Here's what I tried: if (response.data.status == 404) { angular.element(document.getElementById("msg")).css("color", "red"); ...

Close pop-up upon successful AJAX response in ASP.NET MVC

I have a modal in my view that allows me to create a new record in the database. The view for this functionality is contained within a partial view. Below is the code for the view: <script src="~/Scripts/jquery-3.1.1.js"></script> To han ...

"Oops! Vite seems to be facing an issue as RefreshRuntime.injectIntoGlobalHook function is

Our CRA react app has been transitioned from webpack to Vite. Problem: When running the application locally in production mode, I encounter the following error: 1. Uncaught TypeError: RefreshRuntime.injectIntoGlobalHook is not a function at (index):6:16 ...

Which slider was featured in the unity3d.com/5 website?

While browsing the internet, I came across the website and was intrigued by the slider effect featured in the "graphics" section. I am eager to figure out how to replicate that stunning visual effect. ...

Trouble with ScrollView not scrolling on Nativescript-Vue

I am facing an issue with a scrollable view in my project. I have a list of items that should be scrollable, but for some reason it is not scrolling as expected. The structure involves a vertical stack layout wrapped in a scrollview, and inside the stackla ...

“What could be causing the issue of newly added components not appearing on an extjs panel after removing other components?”

Using ExtJs 6 classic, I have a situation where I am dealing with an Ext.panel.Panel that contains dynamically created child Panels and containers. What I do is save references to these containers and remove them from the parent Panel (this) utilizing the ...

Switching off toggle does not switch back to primary theme when clicking again for the second time

When I click the button for the first time, it changes the theme. However, when I click it a second time, nothing happens; it seems like it's stuck on the second theme forever. It should change themes with every click. Can someone please help me with ...