【发布时间】:2014-04-15 01:59:37
【问题描述】:
我尝试将 a little app in AngularJS 从 JavaScript 翻译成 CoffeeScript,作为学习 CoffeeScript 的一种练习。
开头'use strict'
UsrAdmApp = angular.module 'UsrAdmApp', ['ngAnimate', 'ui.bootstrap']
UsrAdmApp.controller 'UsrAdmCtrl', class
constructor: (@$scope, @$http, @$timeout) ->
# Init scope
# etc.
我尝试使用简单的coffee appcoffee.coffee 进行编译,但找不到angular 模块。
ReferenceError: angular is not defined
at Object.<anonymous> (.../appcoffee.coffee:6:15)
at Object.<anonymous> (.../appcoffee.coffee:56:4)
at Module._compile (module.js:456:26)
我尝试了-r angular 选项,但我得到了Error: Cannot find module 'angular'。我尝试将angular.js 文件与咖啡文件放在同一目录中,我也尝试了-r angular.js,让npm install angularjs 将node_modules 文件夹放在同一级别,但我没有编译该脚本.. .
目前我不想使用 yeoman 或 grunt,因为我想先了解整个事情在一个小项目上是如何工作的。
【问题讨论】: