こんにちは、私はいくつかのangular.jsビデオを見ていて、value()メソッドが一種のモジュール全体の定数を設定するために使用されているのを見ました。たとえば、Angular-UIライブラリの設定を次のように設定できます:(coffeescript)
angular.module('app',[])
.value "ui.config",
tinymce:
theme: 'simple'
width: '500'
height: '300'
そして、私のアプリは現在次のようになっています:
window.app = angular.module("app", [ 'ui'])
.config(["$routeProvider", ($routeProvider) ->
$routeProvider
.when "/users",
templateUrl: "assets/templates/users/index.html"
controller: IndexUsersCtrl
.otherwise redirectTo: "/users"
])
.value 'csrf', $('meta[name="csrf-token"]').attr('content') #<---- attention here
IndexUsersCtrl = ($scope) ->
$scope.users = gon.rabl
console.log "I want to log the csrf value here" #<---- then attention
IndexUsersCtrl.$inject = ['$scope']
しかし、アプリモジュールに対応する「app」変数をタップしても、その値を取得できないようです。
ここSTとAngularjsのgoogleグループを読んで、共通のコードbtwnコントローラーを共有する1つの方法はサービスを介することですが、この概念もここに適用されますか?
ありがとう!