2
Что случилось с этим простым угловым приложением:
// app.js
(function() {
'use strict';
angular.module('app', [
'ngRoute',
'ngResource',
'app.weather'
])
.config(['$routeProvider', function ($routeProvider) {
$routeProvider.otherwise({redirectTo: '/'});
}]);
}());
и контроллером и ресурсом:
// weather.js
(function() {
'use strict';
// Resource
angular.module('app.weather',['ngResource'])
.factory('Entry', function($resource) {
return $resource('http://api.openweathermap.org/data/2.5/weather');
});
// Controller
angular
.module('app.weather')
.controller('Weather', Weather);
Weather.$inject = ['$resource'];
function Weather(Entry) {
var vm = this;
var result = Entry.get({q: "London,uk"}, function() {
vm.data = result;
console.log(result);
});
}
}());
Это дает следующее сообщение об ошибке который относится к Entry.get({q: "London,uk"}...
линии:
TypeError: undefined is not a function
at new Weather (weather.js:25)
at Object.invoke (angular.js:4185)
at $get.extend.instance (angular.js:8454)
at angular.js:7700
at forEach (angular.js:331)
at nodeLinkFn (angular.js:7699)
at compositeLinkFn (angular.js:7078)
at compositeLinkFn (angular.js:7081)
at compositeLinkFn (angular.js:7081)
at publicLinkFn (angular.js:6957)
Я проверил другие вопросы по этому поводу, но я не мог уловить проблему.
спасибо человеку. Меня сводило с ума. Приму. – norbertpy
Добро пожаловать! – dfsq