I'm not getting the desired output with the double curly brackets

I'm currently experimenting with deploying an AngularJS build on Heroku, but I'm facing an issue where the content inside the double curly brackets is not displaying as expected. Despite ensuring that my sources are correct, I am unable to pinpoint the exact problem. Below is an excerpt from my index.ejs file:

<!DOCTYPE html>
<html ng-app="rantList" >
<head>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js">    </script>
  <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js">    </script>

</head>
<body >
</div>
<div ng-controller = "RantController as rantList" >
<h1> {{rantList.piece.name}}</h1>
<p> {{rantList.piece.paragraph}} </p>

</div>


<script src=     "http://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>
<script type = "text/javascript" src = "/../app.js"> </script>
<p>{{"Hello"}}</p>
</body>
</html>

This snippet showcases my app.js file:

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

app.controller('RantController', function(){
  this.piece = rant;
});

var rant = {
  name: 'First User',
  paragraph: '....',
}
})();

And here is my server.js file:

var express = require('express');
var app = express();

// Set the port of our application
// process.env.PORT allows Heroku to set the port
var port = process.env.PORT || 8080;

// Set the view engine to ejs
app.set('view engine', 'ejs');

// Allow express to access assets in the public directory
app.use(express.static(__dirname + '/public'));

// Define the home page route
app.get('/', function(req, res) {

// Render the 'index' template using EJS
res.render('index');
});

app.listen(port, function() {
console.log('Our app is running on http://localhost:' + port);
});

In the curly brackets, instead of displaying the desired content like 'First User' and 'Hello World', it shows 'rantList.piece.name' and '{{"Hello World"}}'. Being relatively new to this, any assistance would be greatly appreciated.

Answer №1

When facing an issue like this, the initial step should always be to inspect your browser console for any errors.

Based on the information provided, it seems likely that you are using a Heroku domain. It is important to note that Heroku domains can only be accessed through https. Chrome does not load non-https resources on https URLs, so it is crucial to ensure that all your resources are served over https.

In your particular situation, it appears that your angular and bootstrap libraries are not being included via https. Fortunately, these CDNs do support https, so you just need to update your URLs as follows:

<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.3/angular.min.js"></script>

Your browser console may display an error message similar to the following:

Mixed Content: The page at 'xxx' was loaded over HTTPS, but requested an insecure script 'http://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js'. This request has been blocked; the content must be served over HTTPS. 

It is essential to always monitor your console for errors, as it often provides insights into the root cause of the issue.

Additionally, it seems like there might be a mistake in your app.js path. /../app.js is not a valid URL structure. Without visibility into your file hierarchy, it is challenging to pinpoint the correct path. However, if you follow the structure of the angular seed project, the path should simply be like this:

<script type="text/javascript" src="app.js"></script>

Once again, monitoring the console will likely highlight any discrepancies in your URL paths.

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

What is the best way to detect clicks on numerous images?

Seeking a solution for handling click events on multiple imagemaps within an iOS uiwebview to manage scaling across various iOS devices. While the click handler functions properly for the first image, it fails to work for subsequent images. How can I ensur ...

How can you use the slice() method in Javascript to select all elements in an array except for

Consider this scenario: let myarray = [a, b, c, d, e]; I aim to choose all elements from the array except for c. const myselection = myarray.slice(3, 5); This results in only selecting d and e. To include a and b, I attempted: const myselection = myar ...

How to extract characters from a string within a specified range using regex

I'm currently attempting to implement regex within a jQuery function to replace and mask all characters in a string with 'x' except for the first 4 and last 4 characters. The length of the string can vary. I've managed to successfully m ...

How can I efficiently filter my array or JSON data in JavaScript using multiple criteria, including handling multi values?

One of the challenges posed here is: Some values include more than one item (like active substances: ["Morphine", "Fentanyl"]) Some values repeat themselves (retrospective: "1" for "true"; ward_focused: "1" for true (again)) Unfortunately, the previous ...

Implement the Show/Hide TinyMCE Functionality in your <textarea></textarea> Box

Information I recently added TinyMCE to my website after discovering that a website I frequently visit uses it. While their design and functionality are different, I managed to replicate their look on my own site and now want to implement a specific featu ...

Troubles arising while using ng serve in Angular 2

I'm currently facing an issue during the installation process of an existing Angular application. When trying to run the application using the ng serve command, I encounter the following error message: The "@angular/compiler-cli" package was not prope ...

By default, make the initial element of the list the selected option in an AngularJS select input

I'm running into an issue with setting the first element in my ng-repeat list within a select input. Here is the code snippet causing the problem: <div> <span >OF</span> <select ng-model="eclatementCourante.ordreFabricationId" n ...

A guide on sorting through a multi-dimensional array list in a ReactJS application

I've recently attempted to incorporate a search feature into a multi-array list. The objective is to search for specific keywords within the array, but I encountered an error during my attempts. Array for Searching: const listComponent = [{ i ...

Having trouble iterating through a grouped array in JavaScript?

Regrettably, I am facing issues once again with my grouped messages. Although I have received a lot of assistance from you previously, I still find myself struggling and hesitant to ask for help again. Initially, my objective was to group messages based o ...

What is the process for incorporating a collection in Mongoose?

Trying to clear the Users collection before and after tests: before(function(done) { mongoose.connection.collections['users'].drop(function(err) { mongoose.connection.collections['users'].insert(user, done); }); }); after(func ...

What is the best way to send these values to a JavaScript function and show them one by one on an HTML webpage?

There are 100 values stored in the database. https://i.stack.imgur.com/584Op.jpg I need to retrieve these values from the database using PHP and pass them to JavaScript using Ajax. PHP CODE: for($i=0;$i<=9;$i++) { $random = (10 * $i) + rand(1,10); ...

How to remove every instance of an item in an array based on its unique identifier using JavaScript

Is there a way to clean up an array of objects by removing duplicates with the same id? In this case, I only want to keep the object with id 1. This is my approach: let data = [{ "selected": true, "id": 3, "ProductName": "Aniseed Syrup", ...

transform pixel coordinates to latitude and longitude dimensions

Seeking clarification on how the geo referencing process functions for images. Is there a method to accurately extract latitude and longitude information from this specific line of code? imageBounds = [map.unproject([0, 0], 20), map.unproject([1716,1178], ...

Nodejs client application for maintaining constant communication with an echo server

As someone who is just starting out in the world of nodejs, I recently managed to create an echo server using tutorials from YouTube. While there's nothing wrong with my server code, I am now facing the challenge of developing a client program that ca ...

Modify the PrimeFaces dialog to be modal using client-side code

One of my primefaces dialogs is set up like this: <p:dialog widgetVar="dlg" width="320" height="220" modal="false" closable="false" showHeader="false" resizable="false" position="right,top"> I am looking to make this dialog modal if a certain eleme ...

"The Material UI date picker is encountering an issue with the error prop, which is being evaluated

I have developed a date picker that utilizes the Jalali calendar. While attempting to pass error checking using the error prop in the following code: <LocalizationProvider dateAdapter={AdapterJalali}> <MobileDatePicker label={lab ...

Delay timing for two instances in parallel execution using protractor

I have been using Protractor to automate my application with great success. I can efficiently execute my test cases both sequentially and in parallel. However, when running tests in parallel with 4 instances at a time, it seems to be causing issues with hi ...

Executing AngularJS controller upon view initialization

I am working on an angularJS single page application that loads views per click. My login and Index are combined in one HTML file. I have managed it using ng-show and ng-if directives. The process is as follows: Index.html and IndexController.js: The log ...

Executing a pair of AJAX calls and combining their results within a single div element

My project entails utilizing two AJAX requests The first request loads all the streams The second request retrieves information about online streams Due to lack of combined data from APIs for both online and offline streams, I have successfully loaded ...

Personalizing the service endpoint in Feathers.js: A guide

Is there a way to attach a URL to my user requests that reside in a different service? How can I customize a GET request? const { Service } = require('feathers-sequelize') exports.Users = class Users extends Service { get(id, params) { // ...