Cannot access console.log within Angular UI Router .config()=> {}

I've been working on connecting different parts of a basic Angular application, but I'm facing an issue where my initial view state is not loading. A major problem seems to be that I am unable to log inside the .config set up (even though I have double-checked for correct syntax). From my testing, it appears all my files are in their correct locations.

Can anyone spot any obvious errors?

index.html:

<!DOCTYPE html>
<html>
  <head></head>
    <title>Thing</title>

  <body class="container">

    <div class="row">
      <div class="span12">
        <div class="well" ui-view></div>
      </div>
    </div>

    <!-- dependencies -->
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.3.10/angular.min.js"></script>
    <script src="//angular-ui.github.io/ui-router/release/angular-ui-router.js"></script>
    <!-- css files -->

    <!-- application files -->
    <script src="js/app.js"></script>
    <script src="js/payments.js"></script>

    <!-- Google Maps -->
     <script src="https://maps.googleapis.com/maps/api/js?v=3.exp&libraries=places"></script>
  </body>

</html>

app.js:

var paymentApp = angular.module('paymentApp', ['ui.router'])

.config(function($stateProvider, $urlRouterProvider) {
  $urlRouterProvider.otherwise('/payments')
  // Now set up the states
  console.log("in config")

  $stateProvider
    .state('payments', {
      url: "/payments",
      templateUrl: "view/payments.html"
    })

});

payments.html:

<h1>Payments Page</h1>
<div class="buttons">
  <button>Click Me!</button>
</div>

<div class="search"></div>

<div class="payments"></div>

Answer №1

It's a common oversight - you just need to remember to bootstrap your angular app.

Make sure to include the ng-app directive in your code and specify the module it refers to.

For example:

<html ng-app="paymentApp">

https://docs.angularjs.org/api/ng/directive/ngApp

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

"The event triggers the function with an incorrect parameter, leading to the execution of the function with

Currently, I am working with a map and a corresponding table. The table displays various communities, each of which has a polygon displayed on the map. My goal is to have the polygons highlighted on the map when hovering over a specific element in the tabl ...

Is this example showcasing the use of JavaScript closures?

I have a JavaScript query that may be geared towards beginners: var countries = [ "Bangladesh", "Germany", "Pakistan"]; function checkExistence(arr, input) { for (var i = 0; i < arr.length; i++) { if (arr[i] != input) { a ...

What is the proper way to designate a manifest.json link tag on a limited-access website controlled by Apache shibboleth?

The issue arises when attempting to access the manifest.json file. It has been declared as follows: <link href="manifest.json" rel="manifest"/> Is it possible to declare the manifest tag inline, or what would be the most effective way to declare it ...

Ways to rearrange items in the navigation bar?

I am working with a Bootstrap template and I am trying to adjust the layout to be right-to-left (RTL). Currently, when I set the site title to RTL in the navbar, the buttons in the navbar also switch to RTL alignment. This is not the desired layout I want. ...

In absence of javascript, AJAX comes to the rescue for retrieving data

Is there a way to handle an AJAX get request if the browser does not have JavaScript enabled? Imagine clicking on an image thumbnail that leads you to a controller returning image details and a zoomed-in photo. I aim to use AJAX to display the enlarged p ...

Web scraping with Cheerio in Node.js sometimes yields undefined results

When attempting to extract data from NSE website, I initially tried using the inspect element console: (Edited the question) https://i.sstatic.net/Xq8mZ.png objs = $('div[class="table-wrap"] > table > tbody > tr > td').slic ...

Vue.js is failing to re-render the component even after a change is made to

Utilizing Vue.js for my project. I am working with two object arrays, category and categoryPar. The category array contains names and parent names, while the categoryPar array only contains names. My goal is to display only the categories that belong to t ...

How come the values keep appearing without any loops or subsequent calls being made to the PHP file?

Here is a demo example showcasing 'Server Sent Events(SSE)': Embed HTML code(index.html) : <!DOCTYPE html> <html> <body> <h1>Receiving server updates</h1> <div id="result"></div> <script> if(type ...

What advantages does using 'async' offer for TypeScript functions that already have a Promise return type?

Is there any advantage to declaring a TypeScript function as async if the return type is already a promise? It seems like both methods achieve the same result: function foo(): Promise<Bar> { } //vs async function foo(): Bar { } //Or even async fu ...

Having issues with templateURL not working in AngularJS routeProvider

I've been experimenting with ngRoute and I'm facing an issue with templateURL not working as expected. The functionality works perfectly except for when I attempt to use templateURL. Here are the 4 files involved: test.html <p>{{test}}&l ...

Having some trouble with the JS code, so I decided to switch gears and focus on demonstrating some CSS concepts in

After spending around 3-4 hours trying to fix a demo using JS and CSS, I finally found half of the solution. Despite adding the CSS directly to the element which worked fine, I encountered issues when attempting to use JS. I downloaded the jquery-1.11.3.j ...

Best practices for establishing a conditional statement with JQuery's inArray function

I am working on a code snippet to generate a list of unique random numbers. Each generated number is supposed to be added to an array after checking that it doesn't already exist in the array. However, I seem to be facing some challenges with getting ...

The Vue emit function within a parent-child component relationship is disrupting the v-model binding

Currently troubleshooting a bug in another person's code and looking to minimize the amount of changes needed. Encountering an issue where v-model binding in components is lost when using the $emit functionality to execute functions between child and ...

Encountering a 404 error when attempting to post from a Node.js express app to a

Trying to post to a MySQL database has been giving me a 404 error. I have searched through various posts here, but none of the accepted solutions seem to work for me. I'm struggling to figure out what I am doing wrong. When utilizing a GET request, t ...

Assign the input text field's value programmatically in the code-behind of a C# Asp.net application

I am attempting to change the value of an HTML input field from C# code behind. These inputs are created through a JavaScript loop, so I have not had much success using run at server or assigning values through <%= %>. Below is my script: var mytab ...

Storing a date in MySQL using Vue.js and Node.js

My current tech stack consists of nodejs and express.js for the backend, vuejs for the frontend, and mysql as the database. I am facing an issue where I cannot send a date retrieved from localStorage to my mysql database. Whenever I try to send the date, ...

Class does not have the capability to deserialize an array

I encountered this issue with my code (see image): https://i.sstatic.net/QxI0f.png Here is the snippet of my code: function CheckLoginData() { var user = []; user.Email = $("#tbEmail").val(); user.Password = $("#tbPassword").val(); $.ajax({ type ...

What is the best way to utilize functions in Express to dynamically display content on my Jade template?

I have successfully implemented a user registration and login page, but now I need to determine what content to display based on whether the user is logged in. I found this solution: app.use(function(req, res, next) { db.users.find({rememberToken: req.c ...

Can we not customize a nested component using the 'styled()' function in MUI?

Looking at the code snippet below, my attempt to style an MUI Stack component within an MUI Dialog component seems to be falling short. The Stack styles are not being applied as expected: const CustomDialog = styled(Dialog)(({ theme }) => ({ ' ...

Is the information not displayed in its entirety on the FullCalendar?

I'm currently working with the following code: $('#calendar_1').fullCalendar({ header : { left : 'prev,next today', center : 'title', right : 'month,agendaWeek,agendaDay' ...