我一直在尝试创建一个天气应用程序,我可以从数据库中检索数据。我收到两个错误,我无法弄清楚导致它们的原因。一个错误是语法错误:意外令牌:。代码是:
var app = angular.module('app', []);
app.controller('Ctrl', ['$scope', '$http', function ($scope, $http) {
getForecast($scope.Location.Latitude, $scope.Location.Longitude, false);
getForecast = function (lat, lng, isretry) {
var _weather = []
if (ConnectivityMonitor.isOnline()) {
WundergroundService.getThreeDayForecast(lat, lng).then(function (r) {
if (r.success) {
if (r.data.response.error) {
if (!isretry) {
// retry in 0.5 seconds if there was an error
setTimeout(function () { getForecast(lat, lng, true); }, 5000);
}
$scope.hasWeather = false;
}
else {
angular.forEach(r.data.forecast.simpleforecast.forecastday, function (forecastday) {
if (forecastday.period <= 5) {
_weather.push(forecastday);
}
});
$scope.weather = _weather;
$scope.hasWeather = true;
}
}
function CurrentWeather(lat, lon) {
http://api.wunderground.com/api/e217707248f71e69/conditions/lat_lon
x.innerHTML = "Latitude: " + position.coords.latitude +
"<br>Longitude: " + position.coords.longitude;
"response": {
"version": "0.1",
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
"features": {
"conditions": 1
}
},
错误在响应行上。我在使用的角度cdn上也出错了。与cdn类似的是:错误:[$ controller:ctrlreg] http://errors.angularjs.org/1.6.4/ $ controller / ctrlreg?p0 = MyCtrl at https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js
我的代码是:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Index</title>
<style>
html {
align-content: center;
text-align: center;
color: white;
font-family: 'Times New Roman', Times, serif;
font-size: 12pt;
background-image: url("https://s.w-x.co/lightning_wunder_photo_3.png");
background-repeat: no-repeat;
background-size: cover;
}
</style>
<script type="text/javascript" src="Scripts/jquery-1.10.2.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.4/angular.min.js"></script>
<script type="text/javascript" src="./Scripts/app.js"></script>
<script type="text/javascript" src="./Scripts/Controller.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.8.1/xlsx.full.min.js"></script>
<script src="http://oss.sheetjs.com/js-xlsx/jszip.js"></script>
<script>
$(document).ready(function () {
$(function () {
$("datepicker").datepicker();
});
});
</script>
<script>
var fetch = angular.module('myapp', []);
fetch.controller('userCtrl', ['$scope', '$http', function ($scope, $http) {
$http({
method: 'get',
url: 'Scripts/getData.php'
}).then(function successCallback(response) {
// Store response data
$scope.users = response.data;
});
}]);
</script>
<script>
var app = angular.module("myApp", []);
app.controller("myCtrl", function ($scope) {
$scope.myTxt = "You have not yet clicked submit";
$scope.myFunc = function () {
$scope.myTxt = "You clicked submit!";
}
});
</script>
</head>
<body ng-app="MyApp">
<div ng-controller="MyController" class="container" style="margin-top:50px;">
<ion-view title="Home">
<ion-content class="has-header">
<!-- Display current location's weather data-->
<h3>{{city}}</h3>
<h5><weather-icon icon="current.icon" id="current-icon"></weather-icon> {{current.currently.summary}}</h5>
<a id="Nearest" src="CurrentWeather()" rel="CurrentWeather"></a>
</ion-content>
</ion-view>
<ion-view title="Home">
<ion-content class="has-header">
<!-- Display Weymouth location's weather data-->
<h3></h3>
<h5><ng-model="CurrentWeather()" weather-icon icon="weymouth.icon" id="weymouth-icon"></ng-model="CurrentWeather()"=weather-icon></h5>
<a id="Weymouth" src="Weather()" rel="Home"></a>
</ion-content>
</ion-view>
<div>
<table>
<form method="post">
<tr>
<td>
<!-- Display records -->
<Input type="date" ng-repeat="user in users" class="datepicker">{{date.month/date.day/date.year}}</Input>
</td>
</tr>
<tr>
<td>
<button type="submit" ng-controller="MyCtrl" ng-submit="MyFunc()" onclick="Scripts/getData.php">Get Data</button>
</td>
</tr>
</form>
</table>
</div>
</div>
</body>
</html>
这里出了什么问题?谢谢你的帮助。