Last active
August 29, 2015 14:06
-
-
Save n0m4dz/20caa6d9f4dcad35dbef to your computer and use it in GitHub Desktop.
Angular + Laravel main module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
$injector = angular.injector(['ng']) | |
$injector.invoke(($http, $rootScope, $log)-> | |
$rootScope.$apply(-> | |
$http.get("/api/server") | |
.then((o)-> | |
app = angular.module 'app', [] | |
app.constant 'CONFIGS', | |
'token': o.data.csrf_token | |
'url': o.data.server_url | |
$log.info(o.data) | |
app.run(($rootScope)-> | |
$rootScope.isActive = false | |
return | |
) | |
app.config ($urlRouterProvider)-> | |
$urlRouterProvider | |
.otherwise '/' | |
angular.bootstrap document, ['app'] | |
return | |
) | |
) | |
) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
var $injector; | |
$injector = angular.injector(['ng']); | |
$injector.invoke(function($http, $rootScope, $log) { | |
return $rootScope.$apply(function() { | |
return $http.get("/api/server").then(function(o) { | |
var app; | |
app = angular.module('app', []); | |
app.constant('CONFIGS', { | |
'token': o.data.csrf_token, | |
'url': o.data.server_url | |
}); | |
$log.info(o.data); | |
app.run(function($rootScope) { | |
$rootScope.isActive = false; | |
}); | |
app.config(function($urlRouterProvider) { | |
return $urlRouterProvider.otherwise('/'); | |
}); | |
angular.bootstrap(document, ['app']); | |
}); | |
}); | |
}); | |
}).call(this); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.controller 'appCtrl', ['$scope', '$log', 'CONFIGS', ($scope, $log, $config)-> | |
$log.info($config.url) | |
return | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
'use strict'; | |
app.controller('appCtrl', [ | |
'$scope', '$log', 'CONFIGS', function($scope, $log, $config) { | |
$log.info($config.url); | |
} | |
]); | |
}).call(this); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Route::get('api/server', function(){ | |
return Response::json(array( 'csrf_token' => csrf_token(), 'server_url' => Config::get('app.url'))); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment