I am not forcing the Angular module to conform to my perspective

Hello, I am new to Angular and trying to experiment with some code. However, I seem to be stuck with the app.js file which is throwing an error:

Uncaught SyntaxError: Unexpected token .

Below is the structure of my application, which I obtained by cloning angular-seed and making some modifications.

index.html

<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>Currency Converter</title>  
    <link rel="stylesheet" href="style.css">
    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
    <script src="app.js"></script> 
    <script src="finance.js"></script>
</head>
<body>
    <div ng-app="myApp" ng-controller="MyAppCtrl as app">
        <b>Currency Converter</b>
        <div>
            <input type="number" ng-model="app.amount" required >
            <select ng-model="app.inCurr">
                <option ng-repeat="c in app.currencies">{{c}}</option>
            </select>
        </div>
        <div>
            <input type="number" ng-model="app.amount" required >
            <select ng-model="app.inCurr">
                <option ng-repeat="c in app.currencies">{{c}}</option>
            </select>
        </div>
    </div>  
</body>
</html>

app.js

(function(){
    'use strict';
    angular.module('myApp', ['finance'])
    .controller('MyAppCtrl', ['currencyConverter', function(currencyConverter) {
        this.amount = 1;
        this.inCurr = "EUR";
        this.currencies = currencyConverter.currencies;
    }]);
}());

finance.js

(function(){
    'use strict';
    angular.module('finance', [])
    .factory('currencyConverter', ['$http', function($http) {
        //var yahoo_finance_rest_api=https://query.yahooapis.com/v1/public/yql?   q=select%20*%20from%20yahoo.finance.xchange%20where%20pair%20in%20(%22EURUSD%22%2C%22GBPUSD%22%2C%22EURGBP%22%2C%22CNYUSD%22%2C%22CNYGBP%22%2C%22CNYEUR%22)&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
        var currencies = ['USD', 'EUR', 'CNY', 'GBP'];
    }]);
}());

Can anyone point out what could be causing the issue in this code?

Answer №1

In order for

angular.module('myApp', ['finance'])
to work properly, make sure the statement does not have a semicolon at the end.

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

Removing duplicate values in Vue after sorting

Explore <div v-for="todo in sortedArray"> <b-button block pill variant="outline-info" id="fetchButtonGap" v-model:value="todo.items[0].arrivalTime"> {{fromMilTime(todo.items[0].arrivalTime)}} < ...

The Videojs controls are unresponsive to clicks

Having a strange issue with videojs. I've been attempting to load videojs in the same way as outlined in the documentation, using a dynamic video tag. videojs(document.getElementById('myVideo'), { "controls": true, "autoplay": false, "prelo ...

Utilizing d3.js to implement a scatterplot with zoom functionality that focuses solely on zooming the axis without affecting

Having trouble creating a scatterplot with zoom functionality where only the axis is getting zoomed, not the data itself. Can anyone provide some assistance or insight on what might be wrong? If you're interested in checking out the project, here&apo ...

How can I convert an XML response to JSON in an Ionic 2 HTTP request

Hey there, I'm currently working on making an http request from this rss feed. Here's what I have so far: makeRequest() { this.http.get('http://www.gazetaexpress.com/rss/auto-tech/?xml=1') .subscribe(data => { ...

Issue with Postgres jsonb_to_recordset() function where a key value is displaying as NULL

My goal is to use jsonb_to_recordset() to extract key values. Below is an example of the original jsonb array: select journal.id as journal_id, journal.data::jsonb#>'{context,data,files}' as filelist from journal where id = 'aqpubr0 ...

Trouble sending data with jQuery AJAX request

I've been experimenting with an Ajax request, but I'm having trouble figuring out why this code isn't sending any parameters to the JSP and is throwing a NullPointerException. I've fixed my code now, thanks for the responses. var dfd ...

A step-by-step guide to dynamically adding HTML content on a button click using AngularJS

Can HTML content be added on Button Click event using AngularJS? Here is the code from my index.html: <div class="form-group"> <label for="category"> How Many Questions Do You Want to Add? </label> <div class="col-sm-10"& ...

Deciphering intricate JSON structures using PHP

In my current situation, I am receiving a server response with mixed data and now I need to handle it using PHP. Array ( [14424174] => Array ( [0] => Array ( [id] => 45 ...

Tips for saving a value within a jQuery function for future use in a different function

I have a situation where I receive a value from a jQuery function that I need to pass to another function. How can I achieve this? jQuery.getJSON(url+"&startDate="+startDate+"&endDate="+endDate+"&jobId="+jobId+"&type="+type, function(data) ...

Using PHP to convert an array of SQL rows into a JSON encoded format

I am facing difficulties in converting a PHP array generated from an SQL query to a JSONObject using json_encode. I am utilizing Google Volley for connection. When dealing with a single row result, everything works fine, but when there are multiple rows, ...

How can jQuery determine if multiple selectors are disabled and return true?

I am currently working on a form in which all fields are disabled except for the "textarea" field. The goal is to enable the "valid" button when the user types anything into the textarea while keeping all other inputs disabled. I initially attempted using ...

Optimal Strategies for Interacting with a JSON REST API in Swift 2.0

As I transitioned to Swift, I quickly realized that a lot of the Sample Code I was using no longer functions in Swift 2.0. This has made it challenging for me as a beginner to navigate. I am seeking advice on the best practices for interacting with a REST ...

What methods can we use to test angular controller functions that are not within the scope?

In our Angular Controller, there are a few methods that are not on the scope variable. Is there a way to call or execute those methods inside Jasmine tests? Here is the main code snippet: var testController = TestModule.controller('testController&a ...

Improved Ecommerce Tracking with Google Tag Manager for an Angular JS Website

I am working with a client who has a website built entirely on Angular JS and we have implemented enhanced ecommerce tagging for them through GTM. One of the challenges we are facing is that on an Angular JS site, the data layer does not clear and refresh ...

What methods can a server use to identify if JQuery Ajax's "withCredentials: true" option was utilized for CORS requests?

Currently, I am working on integrating CORS (Cross-origin resource sharing) into a framework. I understand that when an XMLHttpRequest request is made using Jquery's ajax(...) with the withCredentials property set to true, the server must specificall ...

Can the keydown event have an impact on setInterval functionality?

I created a basic snake game using JavaScript and attempted to incorporate a new feature where var trail = []; var tail = 5; var normal_speed = 1000 / 10 var speed = 1000 / 10; var game_status = 0; var my_game; button.addEventListener("click", function ...

Simple Express Path Challenge

I've hit a roadblock in my JavaScript tutorial on Mozilla and could really use some assistance. Below are excerpts from 3 different files: a) In the app.js file, I am trying to locate Router handlers and then present them: //app.js //the fol ...

Guide to building a nested React component

My custom dropdown component requires 2 props: trigger (to activate the dropdown) list (content to display in the dropdown) Below is the implementation of my component: import { useLayer } from "react-laag"; import { ReactElement, useState } fr ...

Struggling with an error while experimenting with tensorflow/teachable machine on vuejs

After experimenting with vuejs and , I encountered an issue while trying to export the model for my project. As I adjusted the syntax to fit Vue, I hit a roadblock when the code returned an error stating "cannot read properties of undefined...." console.lo ...

Unable to install android application due to duplicated code

I created a hybrid app for Android using Ionic v1 and Angular 1 which is currently running smoothly. I have already uploaded it to the Play Store. Now, I have copied the same code to create a new app, changed the name and package path. However, I am facin ...