Cache path for generated AngularJS templates in Grunt Angular Templates

Here is the file structure I am currently working with:

  • src
    • app
    • ticket
      • template.html
    • index.html
    • app.min.js

I have been utilizing grunt-angular-templates for creating a cache, and my configuration looks like this:

    ngtemplates:{
        app:{
            src: 'src/app/**/*.html',
            dest: 'src/templates.js',
            htmlmin: {
                removeComments: true,
                collapseWhitespace: true,
                collapseBooleanAttributes: true
            }
        }
    }

However, the generated templates end up looking like this:

 $templateCache.put('src/app/ticket/template.html', '.......');

What I actually need is for it to be

$templateCache.put('app/ticket/template.html', '.......');

Is there a way I can adjust the path using the configuration?

Answer №1

To make it work, you can specify the current working directory like this:

ngtemplates:{
        app:{
            cwd: 'src/',
            src: 'app/**/*.html',
            dest: 'templates.js',
            htmlmin: {
                removeComments: true,
                collapseWhitespace: true,
                collapseBooleanAttributes: true
            }
        }
    }

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

Angular 2 Error: Unable to access the property 'value' as it is undefined

Whenever I click on the Submit button, this error pops up in the browser console. https://i.sstatic.net/57a5N.jpg In my application, I am attempting to retrieve information about the code uploaded by a Student. I am at a loss as to why this error is bein ...

Having issues with the right margin in HTML5 canvas and struggling to remove the scroll bar

I am struggling with adjusting the margins of my canvas to ensure equal spacing on both sides without any horizontal scroll bars. Desired Outcome: Equal margin on both sides of canvas without any horizontal scroll bars. Issue: The margin-right property i ...

Troubleshooting my HTML5 local storage issues for optimal functionality

I've been working on using HTML5's localstorage to save two variables and load them upon page refresh, but I seem to be encountering some issues when trying to load the saved items: Variables in question: var cookies = 0; var cursors = 0; Savi ...

How can you implement code that responds differently based on whether the user clicks the OK, cancel, or close button in a confirm dialog

What are three buttons in a confirm dialog box? How can JavaScript be used to perform different actions when the "ok" and "cancel" buttons are clicked, without performing any action when the dialog box is closed? ...

Command unitTest controller yields an empty result

I am facing an issue while testing an angular directive. Despite having successfully done it in the past, I seem to have hit a roadblock today. It's probably just a silly mistake. var element, scope, controller; beforeEach(function() { angular.m ...

What is the best way to send an array of objects to a Node.js server?

What is the method for sending an array of objects with user data to the server for verification? I am attempting to pass orderform data to a server for validation and then display it on a different page after redirection. const addProductsToServer = (ev ...

Why is Three.js r70 only rendering the first plane when merging multiple planes together?

Combining multiple planes into one only results in rendering the first plane. I'm attempting to merge planes together to optimize performance as I intend to render a minimum of 4096 planes at once while minimizing draw calls. Currently utilizing Thre ...

Using Vue to turn a string into a mathematical operation

I'm in the process of creating a basic calculator using Vue, but I'm stuck on how to convert a string into a mathematical operation. I've already written the code for building the strings. <template> <div> <input type=&q ...

Use AJAX to send the form instead of using the action attribute

Struggling to get a form to submit using ajax instead of an action attribute, but so far, nothing seems to be working. The PHP script functions correctly when tested with an action submit. I've researched examples, read documentation, asked questions ...

Is it possible to adjust table rows to match the height of the tallest row in the table?

I've been attempting to ensure that all table rows have the same height as the tallest element, without using a fixed value. Setting the height to auto results in each row having different heights, and specifying a fixed value is not ideal because the ...

What is the method for showcasing an image before it has been uploaded?

I must start by apologizing for my English, as I am not the most fluent speaker. Here's where I'm facing a dilemma: I have created an application that allows users to edit questions for a game. These questions are stored on a server and can be ...

Introduction to Angular initial rendering

I have a straightforward question, but unfortunately I am unsure how to search for it. As my initial page loads, I want Angular to automatically display the first content in <div ng-view>. Subsequently, using $routeProvider takes care of reloading t ...

Removing a modal div element in React after navigating

import React, { useState } from "react"; import { useNavigate } from "react-router-dom"; import axios from "axios"; import Cookies from "js-cookie"; const LoginPage = () => { const [email, setEmail] = useState( ...

In my code with javascript onclick, a small link icon keeps appearing in Internet Explorer. How can I eliminate this icon from showing up?

Check out the website at this link: Pay close attention to the 3 slides in the middle section with the 3 links below labeled "99% Satisfaction, New, Studio10" and 2 blue arrow buttons In Internet Explorer versions 7, 8, 9, whenever you click on any of th ...

Newbie in JavaScript - reinitiating my for loop journey

After running an animation in 4 steps, I want it to restart once all the steps are completed. var aSteps = [ { "x": "800", "y": "0" }, { "x": "800", "y": "500" }, { "x": "0", "y": "500" ...

What is the technique to make a *ngFor render items in a random order?

I'm working on creating an application that needs to display elements in a random order. However, due to restrictions within the application, I am unable to modify the ngFor directive. How can I achieve displaying ngFor content randomly? ...

Angular ng-repeat failing to recognize updates

When using the ng-repeat to iterate through a JSON response obtained via http.get(), I encounter a situation where, inside the success() callback, I utilize a for-loop to create a new array that needs to be processed by another ng-repeat. Here is a snippe ...

Swap the content of one div with another div using client-side code only

Currently, I am in the process of developing my personal website. To enhance user experience, I have implemented a vertical navigation bar on the left side of the page. My goal is to replace the content of a specific div with content from other HTML files ...

What are the best tools to develop a browser-based 2D top-down soccer simulation?

I'm looking to create a 2D top-down soccer simulation game for web browsers using modern technologies and without the need for additional plugins like Flash or Silverlight, making it compatible with mobile devices as well. The game will be AI-controll ...

Troubleshooting Issue with jQuery replaceWith in Loop

Trying to make it so that when the update button is clicked, the text on the left side becomes an input box: Click the update button and the text on the left will be an input box However, instead of just one input box appearing, all the text on the left s ...