I am building a small photo application to learn AngularJS 1.3. I come from a PHP background so conceptually this is rather different for me :)
I\'d like to pass a v
I wonder whether this would be the best practice or not. However If the value doesn't need to be secure, one of the most simple way to pass constant values from server is something like this.
In html.
<script type="text/javascript">
var _config = {
key1: server_value1,
key2: server_value2
};
</script>
In angular module run method.
angular.module('yourapp', [])
.run(function($rootScope) {
$rootScope.config = _config;
});
In your controller.
console.log($scope.config);
Did you managed to have Angular and Blade syntax in order? In my case I changed what Laravel uses for echoing variables and evaluating expressions
this way setting at routes.php
:
Blade::setContentTags('[[', ']]'); // for variables and all things Blade
Blade::setEscapedContentTags(',.', '.,'); // for escaped data
I'm not sure about how a good practice is but time to time I set some ng-init
directives this way:
Blade template
<div ng-controller="mainController" ng-init="constants={upload_url:'[[$upload_url]]'}">
...
</div>
View
The way I obtain a rendered view this way:
<div ng-controller="mainController" ng-init="constants={upload_url:'some_url_string'}">
...
</div>
Then you could reach it from a controller and use it for ng-Route
this way:
$scope.constants.upload_url