How can I pass a Laravel variable into my AngularJS view?

后端 未结 2 1478
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-19 00:06

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

2条回答
  •  暖寄归人
    2021-01-19 00:44

    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.

    
    

    In angular module run method.

    angular.module('yourapp', [])
        .run(function($rootScope) {
            $rootScope.config = _config;
        });
    

    In your controller.

    console.log($scope.config);
    

提交回复
热议问题