ファクトリを作成し、各コントローラーでクロスルートを使用しようとしていますが、どうやら何か間違っているようです...
アプリ:
var app = angular.module('sam', ['ngRoute', 'ngGrid', 'ui.bootstrap']);
工場
app.factory("User",function(){
return {};
});
ルート
// configure our routes
app.config(function($routeProvider) {
$routeProvider
// route for the main page which will direct to the buildings page
.when('/', {
templateUrl : 'web/pages/buildings.html',
controller : 'mainController',
controllerAs : 'buildings'
})
});
コントローラー
app.controller('mainController', ['$filter', '$http','$log', function($filter, $http, $log, User){
$log.log('hello!!!!!', User);
}]);
これは次を出力します:hello!!!!! undefined