嗨,这是我在角度的第一天,并尝试使用一些代码,但是我迷失了app.js文件,这会导致错误Uncaught SyntaxError: Unexpected token .
这是我的应用程序结构,我从angular-seed克隆并进行了一些清理。
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'];
}]);
}());
知道这段代码出了什么问题吗?
答案 0 :(得分:0)
angular.module('myApp', ['finance']);
,;
终止声明。删除它,它会工作。