【发布时间】:2013-11-29 07:37:19
【问题描述】:
我无法在我的 AngularJS + Coffeescript 项目中使用最简单的指令。
我在 directives.coffee 中有这段代码:
'use strict'
app_name = "myApp"
app = angular.module "#{app_name}.directives", []
# Directive to include the version number of my project
app.directive 'appVersion', [
'version', (version) ->
(scope, element, attrs) ->
element.text version
]
# Hello world directive
app.directive 'hello', () ->
restict: 'E'
template: '<div>Hello World</div>'
在我的模板中,当我这样做时
<span app-version></span>
<hello></hello>
然后出现版本号(0.1),表明第一个指令正常工作,但标签没有被任何东西替换。
知道我做错了什么吗?
我也试过了,也没用:
# Hello world directive
app.directive 'hello', ->
class Habit
constructor: ->
restict: 'E'
template: '<div>Hello World</div>'
【问题讨论】:
标签: javascript angularjs coffeescript angularjs-directive