Unable to access TemplateUrl in ngRoute

I'm currently working with ngRoute in AngularJS. I have created an index.php file with an embedded ng-view div connected to my app.js file, which in turn contains my routeProvider. However, I am facing issues when trying to specify the templateUrl for a URL.

Here is the structure of my project:

nameApp/
├── dist/
│   ├─ html/
│   │   ├── index.php
│   │   └── connexion.php  
│   ├── js/
│   │    ├── app.js
│   └────└── connexion.php 

Contents of my index.php file:

<body ng-app="app">

   <div ng-view></div>

    <script src="https://code.jquery.com/jquery-2.2.4.js"   integrity="sha256-iT6Q9iMJYuQiMWNd9lDyBUStIq/8PuOW33aOqmvFpqI="   crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.5/angular.min.js"></script>
    <script src="https://code.angularjs.org/1.5.5/angular-route.js"></script>
    <script src="/js/app.js"></script>
</body>

Contents of my app.js file:

var myApp = angular.module('app', ['ngCookies','ngRoute']);

myApp.config(function($routeProvider) {
    $routeProvider
        .when('/login', {$templateUrl: 'connexion.php'})
        .when('/test', {$templateUrl: 'test.php'})
        .otherwise({redirectTo: '/login1'});

        console.log("index.js");
});

When I visit the URL xxx/html/#/login, I expect to see my connexion.php file, however I am greeted with a blank page. Any assistance would be greatly appreciated. Thank you :)

Answer №1

Remove the dollar sign from $templateUrl in the code snippet below:

var myApp = angular.module('app', ['ngCookies','ngRoute']);

myApp.config(function($routeProvider) {
    $routeProvider
        .when('/login', {templateUrl: 'connexion.php'})
        .when('/test', {templateUrl: 'test.php'})
        //It seems 'login1' should actually be 'login''
        .otherwise({redirectTo: '/login'});

        console.log("index.js");
});

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

Using Express.js to transform req.body into a POST encoded string

I need to convert the req.body object into a POST encoded string using the express.bodyParser middleware. Is there a way to achieve this? For example: Name: Jane Doe Age: 30 City: Los Angeles Should become: Name=Jane+Doe&Age=30&City=Los+Angeles ...

Unlocking the Power of Typescript and ReactJS: Maximizing Efficiency with Previous State

I'm encountering difficulties implementing the previous state in React 18 with Typescript version 4.8.3. Here is my refreshToken code and I'm receiving the following error: Value of type '(prev: any) => any' has no properties in c ...

Developing a ReactJS counter component that dynamically increments by a custom value specified in props and saved in the component's state

Here is an example code snippet that demonstrates functionality. It works in Firefox but had issues in Chrome. By clicking buttons, the number next to the word "Count" increases based on the value of the button clicked (1, 5, or 10). Code for Desired Out ...

What is the best way to ensure that my grid remains contained within its designated area?

I need to incorporate a grid of 16x16 or 64x64 into my layout without it overflowing. I'm considering using flexbox, but unsure of the implementation process. My goal is to have the grid resize based on the container size rather than exceeding its bou ...

Retrieve the JavaScript object that was initialized within a function

As I venture into the world of working with javascript objects and php objects, I've encountered an issue. While everything seems to be functioning correctly so far, I'm having trouble accessing the javascript object created in the ajax success r ...

Troubleshooting React and Material-UI: Adjusting <slider> component for use with personalized data

I am facing a challenge with using the Material-UI slider to showcase API data. The unique aspect here is that the slider is intended for displaying data without any interactivity. Encountering an error message: Slider.js:91 Uncaught TypeError: nearest.to ...

Does binary search maintain its usual efficiency?

Does binary searching remain efficient and effective if an array inherits from an object? ...

Tips on building an immersive interactive panoramic website

I have a vision for a website that will simulate being in a room, where users can explore the space with limited panoramic views - allowing them to look up/down 30 degrees and left/right 45 degrees. In addition, I would like to integrate interactive object ...

In certain Express app files, the use of Sequelize modules may result in a return value of undefined

Objective - To implement a middleware-like callback in userHandler located in util.js for certain express routes in an express app, created using express-generator and sequelize-cli. Expected Outcome - Utilize the user model successfully in routes and use ...

Display the accurate prompt in the event of 2 `catch` statements

elementX.isPresent() .then(() => { elementX.all(by.cssContainingText('option', text)).click() .catch(error => { throw {message: "Unable to select text in dropdown box"} ...

What is the best approach to ensure mobile responsiveness and properly space the TV show div?

How can I center the searched images of shows and add spacing below each image? The 12-column grid is not behaving properly and the images are aligned correctly on desktop but not on mobile. Any suggestions on how to fix this using CSS and Bootstrap? The g ...

Customizing the appearance of a Form.Check (checkbox) component in React Bootstrap

I am new to React and Bootstrap. I have a question about styling Form.Check (checkbox) components. How can I customize the default appearance to achieve a different look, such as a switch or another style? Here is what I have attempted so far (I tried app ...

Is there an easy method to verify if the local storage is devoid of any data?

Query is named aptly; seeking to verify in a conditional statement. ...

Challenge with Combining jQueryUI Tabs and AngularJS

I am encountering an issue with dynamically generating tabs using jQuery UI and AngularJS. I have created a directive to call the Tabs(jQuery-UI) initialization on a div tag that contains ul > li> a elements generated with ng-repeat. The problem se ...

Using promises and the fetch function to connect to a database

I am attempting to utilize promises with the fetch() function in order to access MongoDB from the front-end, but I am encountering some issues. var Promise = () => ( new Promise((resolve, reject) => { //perform certain actions, make requests ...

Plan the timing of dispatch in the reducer

While solutions like redux thunk exist for dispatching actions asynchronously, I recently encountered a situation like the one below: import {store} from "./store"; const initialState = { todos: [] } ​ function todoApp(state = initialState, action) { ...

The connection between Angular and express.js often requires the use

Currently, I am utilizing express 4.1.0 and angular 1.2.12. Displayed below is a snippet of my client-side code: $http.get(data_url + '/stickers.json') .success(function (data, status, headers, config) { // perform action }) .error(function ...

Issues with local storage ternary expression in React are causing unexpected behavior

I am attempting to accomplish this task. const userToken = localStorage.getItem('token') {userToken.length ? null : <div className='registerLogin'> Register... </div> } The ternary operator is not working ...

Encoding identification data from JSON using ColdFusion

Hello everyone, I've been puzzling over how to intercept and encrypt database record ID from a JSON request in ColdFusion. Below is the code I have so far, along with my unsuccessful attempt. Any assistance would be greatly appreciated. <cfquery ...

Using Formik with Material UI's TextField component and passing a 'label' prop to the Field component

Currently, I am in the process of creating a form with Formik and Material UI. I have implemented the Formik component as follows: Within my Input component, the following code is used: const Input = ({ field, form: { errors } }) => { const errorMes ...