そのため、Angular を使用して小さなファクトリを作成し、ローカルの json ファイルを取得しました。そのデータをコントローラに渡したいのですが、ファクトリ名が見つからず、「未解決の変数」と表示されます。
これが、今のところ関連していると思われるコードのスニペットです。
(function () {
var app = angular.module('locatieTool', ['ngRoute']);
app.controller('teamController', function ($scope) {
function init () {
dataFactory.getTeams().success(function(data) {
$scope.teams = data
});
}
init();
console.log($scope.teams);
});
// factory
app.factory('dataFactory', function($http) {
var team = {};
//get local data
team.getTeams = function() {
return $http.get ('http://localhost:4040/');
};
return team;
});
})();
私の目標は、データでできることよりも、$scope.teams をコンソール ログに記録することです。