3
Angular.js:.value()是设置应用程序广泛常量的正确方法以及如何在控制器中检索它的正确方法
嗨,我在那里观看了几个angular.js视频,并看到value()方法用于设置一种模块范围的常量。例如,可以像这样设置Angular-UI库的配置:(咖啡脚本) 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 …